I have repo method, that update entry in database. Here is code from repo method
public async Task<string> UpdateProfile(string email, string firstname, string lastname, DateTime birthday)
{
string result;
var user = _context.AspNetUsers.Where(x => x.Email == email).FirstOrDefault();
user.FirstName = firstname;
user.LastName = lastname;
user.Birthday = birthday;
await _context.SaveChangesAsync();
result = "Updated";
return result;
}
And here is how I call it from controller
[HttpPost]
public JsonResult UpdateProfile([FromBody] ProfileViewModel profile)
{
var result = _profile.UpdateProfile(profile.Email, profile.FirstName, profile.LastName, profile.Birthday);
return Json(result);
}
But in postman I see Bad object, but entry is updated.
Why I get this and how I can fix this?
Thank's for help.
Bad Request?var result = await _profile.UpdateProfile(profile.Email, profile.FirstName, profile.LastName, profile.Birthday);