public void Destroy(ContactVM contactVm) { var c = db.Contacts.Where(contact => contact.ContactID == contactVm.ContactID).SingleOrDefault(); if (c != null) { db.Contacts.Remove(c); db.SaveChanges(); Clients.Others.destroy(contactVm); } }
public void Update(ContactVM contactVm) { var c = db.Contacts.Where(contact => contact.ContactID == contactVm.ContactID).SingleOrDefault(); if (c != null) { c.FirstName = contactVm.FirstName; c.LastName = contactVm.LastName; c.Email = contactVm.Email; c.Company = contactVm.Company; c.PhoneNumber = contactVm.PhoneNumber; db.SaveChanges(); Clients.Others.update(contactVm); } }
public ContactVM Create(ContactVM contactVm) { var c = new Contact { FirstName = contactVm.FirstName, LastName = contactVm.LastName, Email = contactVm.Email, Company = contactVm.Company, PhoneNumber = contactVm.PhoneNumber, SubmittedDate = DateTime.UtcNow, }; db.Contacts.Add(c); db.SaveChanges(); contactVm.ContactID = c.ContactID; Clients.Others.create(contactVm); return contactVm; }