2016-11-25 85 views
1

我試圖用一些columns.File上傳沿uplode文件成功地偏偏剩餘列取[對象對象]類型爲什麼數據庫中存儲的翻譯:鍵入

public partial class CreateUserIdentity 
    { 
     public int Id { get; set; } 
     public string Email { get; set; } 
     public string Image { get; set; } 
     public string password { get; set; } 
    } 

AngularJs

 var description = { 
       Passwoed: $scope.FileDescription, 
      Email : $scope.Email 
      } 
      FileUploadService.UploadFile($scope.SelectedFileForUpload, description 

       ).then(function (d) { 
}); 

的mvc控制器

[HttpPost] 
     public JsonResult SaveFiles(string description) 
     { 
      if (Request.Files != null) 
      { 
       CreateUserIdentity f = new CreateUserIdentity 
        { 
         Image = actualFileName, 
         Email = description, 
        }; 
        using (ProjectsEntities dc = new ProjectsEntities()) 
        { 
         dc.CreateUserIdentities.Add(f); 
         dc.SaveChanges(); 
         Message = "File uploaded successfully"; 
         flag = true; 
        } 
       } 

return new JsonResult { Data = new { Message = Message, Status = flag } }; 

回答

1

description您發送不是string - 它是由EmailPasswoed的對象 - 類型正確的休息控制器,並使用Email = description.Email

Alertatively你可以從發送$scope.Email而不是將其包裝在description-Object中,這應該也可以工作(如果您不需要屬性Passwoed)。

相關問題