MD Gosoddin MD Gosoddin - 7 days ago 5
AngularJS Question

Why Database Storing [object object] type

I'm trying to uplode File along with some columns.File Uploading sucessfully but why Remaining column taking [object object] type

Table

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 Controller

[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 } };

Answer

The description you are sending is not a string - it is an object consisting of Email and Passwoed - type that correctly in your rest-controller and use Email = description.Email

Alertatively you can you send $scope.Email from the angular-side instead of wrapping it in an description-Object, that should work as well (if you don't need the attribute Passwoed.

Comments