Ejemplo n.º 1
0
        public ActionResult Delete(PhonesCreateVM phonesVM)
        {
            unitOfWork.PhoneRepository.Delete(phonesVM.ID);
            unitOfWork.Save();

            return(RedirectToAction("Index/" + phonesVM.ContactId));
        }
Ejemplo n.º 2
0
        public ActionResult Create(int?contactId)
        {
            if (!contactId.HasValue)
            {
                return(RedirectToAction("Index"));
            }

            PhonesCreateVM model = new PhonesCreateVM();

            model.ContactId = contactId.Value;

            return(View(model));
        }
Ejemplo n.º 3
0
        public ActionResult Create(PhonesCreateVM model)
        {
            if (ModelState.IsValid)
            {
                Phone phone = new Phone {
                    ID = model.ID, Type = model.Type, Number = model.Number, ContactId = model.ContactId
                };
                if (model.ID <= 0)
                {
                    unitOfWork.PhoneRepository.Insert(phone);
                }
                else
                {
                    unitOfWork.PhoneRepository.Update(phone);
                }
                unitOfWork.Save();

                return(RedirectToAction("Index/" + phone.ContactId));
            }
            return(View(model));
        }
Ejemplo n.º 4
0
        public ActionResult Delete(int?id)
        {
            if (!id.HasValue)
            {
                return(RedirectToAction("Index"));
            }

            Phone phone = unitOfWork.PhoneRepository.GetById(id.Value);

            if (phone == null)
            {
                return(Redirect("~/Error/PageNotFound"));
            }

            PhonesCreateVM model = new PhonesCreateVM();

            model.ID        = phone.ID;
            model.ContactId = phone.ContactId;
            model.Number    = phone.Number;
            model.Type      = phone.Type;

            return(View(model));
        }