Created
March 15, 2017 09:50
-
-
Save tibinthomas/92792657c8da36ab6721272557c5af39 to your computer and use it in GitHub Desktop.
Error at _context.SaveChanges();
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[HttpPost] | |
public ViewResult Save(Customer customer ) | |
{ | |
if (customer.Id == 0) | |
{ | |
_context.Customers.Add(customer); | |
} | |
else | |
{ | |
var customerInDB = _context.Customers.Single(c => c.Id == customer.Id); | |
//TryUpdateModel(customer, "", new String[] {"Name", "Email"} ); | |
//Mapper.Map(customer, customerinDb) | |
customerInDB.Name = customer.Name; | |
customerInDB.Birthdate = customer.Birthdate; | |
customerInDB.IsSubscribedToNewsletter = customer.IsSubscribedToNewsletter; | |
customerInDB.MembershipType = customer.MembershipType; | |
_context.SaveChanges(); | |
} | |
_context.SaveChanges(); | |
RedirectToAction("Index", "Customers"); | |
return View(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment