public IHttpActionResult UpdateUser([FromBody] Person updatedUser) { if (updatedUser == null) { return(BadRequest()); } var currentUser = GetCurrentUser(updatedUser); if (currentUser == null) { return(NotFound()); } Person user = new Person() { Name = updatedUser.Name, Password = updatedUser.Password, Surname = updatedUser.Surname, Email = updatedUser.Email, ID = updatedUser.ID, SubjectList = updatedUser.SubjectList }; if (user.SubjectList == null) { using (var db = new UniBinderEF()) { db.People.Attach(user); if (user.Password != null) { db.Entry(user).Property(x => x.Password).IsModified = true; } db.Entry(user).Property(x => x.Name).IsModified = true; db.Entry(user).Property(x => x.Surname).IsModified = true; db.Entry(user).Property(x => x.Email).IsModified = true; try { db.SaveChanges(); } catch (Exception) { return(BadRequest()); } } return(Ok()); } else { userDataInserter.LinkSubjectsToPersonDataTable(user); //userDataInserter.LinkSubjectsToPersonWithDel(user); //slower by 1.5 sec return(Ok()); } }
public void RemoveMatch(Guid id2) { using (var context = new UniBinderEF()) { var match = context.MatchedPeoples.Where(x => x.SecondPersonID == id2).FirstOrDefault(); context.Entry(match).State = System.Data.Entity.EntityState.Deleted; context.SaveChanges(); } }
public void Update(Person entity) { _dbContext.Entry(entity).State = System.Data.Entity.EntityState.Modified; _dbContext.SaveChanges(); }
public void Update(PersonSubject entity) { _dbContext.Entry(entity).State = System.Data.Entity.EntityState.Modified; }