Beispiel #1
0
        /// <summary>
        /// Get Action for Delete
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Delete(int id)
        {
            var contact        = new ContactProject.Models.ContactModel();
            var contactDetails = contactRepository.GetContactByID(id);

            if (contactDetails != null)
            {
                contact.FirstName = contactDetails.FirstName;
                contact.LastName  = contactDetails.LastName;
                contact.PhoneNo   = contactDetails.PhoneNo;
                contact.EMail     = contactDetails.EMail;
                contact.Status    = contactDetails.Status;
            }
            return(View(contact));
        }
Beispiel #2
0
        public ActionResult Delete(int id, ContactProject.Models.ContactModel contactDetails)
        {
            try
            {
                var contact = contactRepository.GetContactByID(id);
                contact.Status = false;  // Inactive  - Soft delete functionality as per request in interview
                contactRepository.DeleteContact(contact);
                contactRepository.Save();

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Beispiel #3
0
 public ActionResult Create(ContactProject.Models.ContactModel contactDetails)
 {
     try
     {
         var contact = new Contact();
         if (ModelState.IsValid)
         {
             //contact.ContactId = contactDetails.ContactId;
             contact.FirstName = contactDetails.FirstName;
             contact.LastName  = contactDetails.LastName;
             contact.PhoneNo   = contactDetails.PhoneNo;
             contact.EMail     = contactDetails.EMail;
             contact.Status    = true; // Active
             contactRepository.InsertContact(contact);
             contactRepository.Save();
             return(RedirectToAction("Index"));
         }
         return(View());
     }
     catch
     {
         return(View());
     }
 }