public void SaveContactDetail(ContactDetail contactDetail) { var existingContact = GetContactDetail(contactDetail.Id); if (existingContact != null) { existingContact.FirstName = contactDetail.FirstName; existingContact.LastName = contactDetail.LastName; existingContact.Email = contactDetail.Email; existingContact.PhoneNumber = contactDetail.PhoneNumber; existingContact.Status = contactDetail.Status; } else { if (contactDetail.Id == Guid.Empty) { contactDetail.Id = Guid.NewGuid(); } dbContext.ContactDetails.Add(contactDetail); } dbContext.SaveChanges(); }
public void SaveLogin(Login login) { var existingContact = dbContext.Logins.FirstOrDefault(l => l.Id == login.Id); if (existingContact != null) { existingContact.UserName = login.UserName; existingContact.Password = login.Password; } else { dbContext.Logins.Add(login); } dbContext.SaveChanges(); }