public void ChangeStatus(int cid) { using (DB_A6BB95_ContactManageEntities context = new DB_A6BB95_ContactManageEntities()) { var contact = context.Contacts.Find(cid); if (contact == null) { throw new Exception("Given contact does not exist"); } contact.LastUpdatedTimeIST = CommonFunctionality.GetISTTime(); contact.Status = !contact.Status; context.Entry(contact).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } }
public void EditContact(ContactVM.EditContactInput input) { ValidateUser(input, input.Id); try { Mapper.CreateMap <ContactVM.EditContactInput, Contact>(); var contact = Mapper.Map <ContactVM.EditContactInput, Contact>(input); using (DB_A6BB95_ContactManageEntities context = new DB_A6BB95_ContactManageEntities()) { contact.LastUpdatedTimeIST = CommonFunctionality.GetISTTime(); context.Entry(contact).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } } catch (Exception ex) { throw; } }
public int CreateContact(ContactVM.AddContactInput input) { ValidateUser(input); //mobile number uniqueness try { Mapper.CreateMap <ContactVM.AddContactInput, Contact>(); var contact = Mapper.Map <ContactVM.AddContactInput, Contact>(input); contact.Status = true; using (DB_A6BB95_ContactManageEntities context = new DB_A6BB95_ContactManageEntities()) { contact.CreatedTimeIST = CommonFunctionality.GetISTTime(); context.Contacts.Add(contact); context.SaveChanges(); return(contact.Id); } } catch (Exception ex) { throw; } }