public PhoneBookUser CreateUser(PhoneBookUser user) { var result = _context.Add(user); _context.SaveChanges(); if (result != null) { return(user); } return(null); }
public bool UpdateUser(int id, PhoneBookUser user) { var existingPhoneBookUser = _context.PhoneBookUsers.Where(x => x.Id == id).FirstOrDefault(); if (existingPhoneBookUser != null) { existingPhoneBookUser = user; _context.PhoneBookUsers.Update(existingPhoneBookUser); _context.SaveChanges(); return(true); } return(false); }