示例#1
0
        // GET: Customer/Delete/5
        public ActionResult Delete(int id)
        {
            var customer = _unitOfWork.Customers.Get(id);
            var model = new CustomerViewModel() {FirstName = customer.FirstName, LastName = customer.LastName, Email = customer.Email};

            return PartialView("_DeletePartial", model);
        }
示例#2
0
        public ActionResult Delete(int id, CustomerViewModel model)
        {
            try
            {
                var existingRecord = _unitOfWork.Customers.Get(id);
                _unitOfWork.Customers.Delete(existingRecord);

                _unitOfWork.SaveChanges();

                return RedirectToAction("Index");
            }
            catch
            {
                return PartialView("_DeletePartial");
            }
        }
示例#3
0
        public ActionResult Create(CustomerViewModel model)
        {
            try
            {
                var customer = new Customer()
                {
                    FirstName = model.FirstName,
                    LastName = model.LastName,
                    Email = model.Email.ToLower()
                };
                _unitOfWork.Customers.Add(customer);

                _unitOfWork.SaveChanges();

                return RedirectToAction("Index");
            }
            catch
            {
                return PartialView("_CreateEditPartial");
            }
        }
示例#4
0
        public ActionResult Edit(int id, CustomerViewModel model)
        {
            try
            {
                var existingRecord = _unitOfWork.Customers.Get(id);
                existingRecord.FirstName = model.FirstName;
                existingRecord.LastName = model.LastName;
                existingRecord.Email = model.Email;

                _unitOfWork.SaveChanges();

                return RedirectToAction("Index");
            }
            catch
            {
                return PartialView("_CreateEditPartial");
            }
        }
示例#5
0
        // GET: Customer/Edit/5
        public ActionResult Edit(int id)
        {
            var customer = _unitOfWork.Customers.Get(id);
            var model = new CustomerViewModel()
            {
                Id = customer.Id,
                FirstName = customer.FirstName,
                LastName = customer.LastName,
                Email = customer.Email
            };

            return PartialView("_CreateEditPartial", model);
        }