예제 #1
0
 public ActionResult Test()
 {
     var c = new Contact
     {
         ContactID = 0,
         FirstName = "f",
         LastName = "z",
         Email = "q",
         PhoneNumber = "c",
         Company = "p"
     };
     return null;
 }
 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;
 }
 public async Task<ActionResult> Contacts_Create(Contact model)
 {
     using (var contactsDB = new ContactContext())
     {
         var contact = new Contact
         {
             FirstName = model.FirstName,
             LastName = model.LastName,
             Email = model.Email,
             Company = model.Company,
             PhoneNumber = model.PhoneNumber,
             SubmittedDate = DateTime.UtcNow,
         };
         contactsDB.Contacts.Add(contact);
         await contactsDB.SaveChangesAsync();
     }
     return Json(model);
 }
 public async Task<ActionResult> Contacts_Update(Contact models)
 {
     using (var contactsDB = new ContactContext())
     {
         var update = contactsDB.Contacts
             .Where(c => c.ContactID == models.ContactID)
             .SingleOrDefault();
         if (update != null)
         {
             update.FirstName = models.FirstName;
             update.LastName = models.LastName;
             update.Email = models.Email;
             update.Company = models.Company;
             update.PhoneNumber = models.PhoneNumber;
             await contactsDB.SaveChangesAsync();
         }
         return Json(update);
     }
 }