public void UpdateLocations(data.Locations update) { // calling Update would mark every property as Modified. // this way will only mark the changed properties as Modified. _db.Entry(_db.Locations.Find(update.Id)).CurrentValues.SetValues(Mapper.Map(update)); }
// Updates a user public void UpdateUser(User user) { _db.Entry(_db.Users.FirstOrDefault(x => x.FirstName == user.FirstName && x.LastName == user.LastName)).CurrentValues.SetValues(Mapper.Map(user, GetLocationId(user.LocationName), GetUserID(user.FirstName, user.LastName))); }