コード例 #1
0
 public void UpdateContact(Contact contact)
 {
     ContactRepository.Update(contact);
     SaveContact();
 }
コード例 #2
0
 public void CreateContact(Contact contact)
 {
     ContactRepository.Add(contact);
     SaveContact();
 }
コード例 #3
0
 public void DeleteContact(Contact contact)
 {
     ContactRepository.Delete(contact);
     SaveContact();
 }
コード例 #4
0
        public ActionResult Create(CreateViewModel createViewModel)
        {

            if (!ModelState.IsValid)
            {
                return View(createViewModel);
            }
            var selectedPartner = PartnerService.FindById(createViewModel.DropDownList_Partner_Property.SelectedPartner);
            var contact = new Contact()
            {
                Name = createViewModel.Name,
                Position = createViewModel.Position,
                Email = createViewModel.Email,
                Phone = createViewModel.Phone,
                Note = createViewModel.Note,
                IsMale = createViewModel.IsMale,
                IsBooker = createViewModel.IsBooker,
                Partner = selectedPartner,
            };

            if (!String.IsNullOrEmpty(createViewModel.Birthday))
            {
                contact.Birthday = DateTime.ParseExact(createViewModel.Birthday, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            }
            else
            {
                contact.Birthday = null;
            }

            if (createViewModel.DropDownList_Partner_Property.SelectedPartner != -1)
            {
                contact.PartnerId = createViewModel.DropDownList_Partner_Property.SelectedPartner;
            }
            else
            {
                contact.PartnerId = null;
            }

            ContactService.CreateContact(contact);

            TempData["ContactId"] = contact.ContactId;
            TempData["ContactName"] = contact.Name;
            TempData["Message"] = DocumentsMessage.CreateSuccess;

            return RedirectToAction("index", "contacts");
        }