示例#1
0
 public bool DeleteContact(Contact contact)
 {
     if (contact == null) return false;
     _unitOfWork.ContactRepository.Delete(contact);
     _unitOfWork.Save();
     return true;
 }
示例#2
0
 //
 // GET: /Contact/Create
 public ActionResult Create(int fdpId)
 {
     ViewBag.FDPName = _contactService.FindById(fdpId).FDP.Name;
     ViewBag.FDPID = fdpId;
     var contact = new Contact { FDPID = fdpId };
     return View("Create", contact);
 }
        public void CanDoEditPostBack()
        {
            //ACT
            var contact = new Contact { ContactID = 1, FDPID = 1, FirstName = "Kebede", LastName = "Molla", PhoneNo = "251116123456" };
            var redirectToRouteResult = _contactController.Create(contact) as RedirectToRouteResult;

            //Assert
            Assert.NotNull(redirectToRouteResult);
            Assert.AreEqual("Index", redirectToRouteResult.RouteValues["Action"]);
            Assert.AreEqual("Contact", redirectToRouteResult.RouteValues["controller"]);
        }
示例#4
0
 public ActionResult Create(Contact contact)
 {
     if (ModelState.IsValid)
     {
         _contactService.AddContact(contact);
         return RedirectToAction("Index", new { fdpId = contact.FDPID });
     }
     ViewBag.FDPName = _contactService.FindById(contact.ContactID).FDP.Name;
     ViewBag.FDPID = contact.FDPID;
     return View("Create", contact);
 }
示例#5
0
 public bool EditContact(Contact contact)
 {
     _unitOfWork.ContactRepository.Edit(contact);
     _unitOfWork.Save();
     return true;
 }
示例#6
0
 public bool AddContact(Contact contact)
 {
     _unitOfWork.ContactRepository.Add(contact);
     _unitOfWork.Save();
     return true;
 }