public void UpdateContact(Contact contact)
 {
     ContactRepository.Update(contact);
     SaveContact();
 }
 public void CreateContact(Contact contact)
 {
     ContactRepository.Add(contact);
     SaveContact();
 }
 public void DeleteContact(Contact contact)
 {
     ContactRepository.Delete(contact);
     SaveContact();
 }
        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");
        }