예제 #1
0
        }// end addAccount

        public ActionResult EditAccount(int?id)
        {
            try
            {
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
                CustomerAccount act = actRepo.GetById((int)id);
                if (act == null)
                {
                    return(HttpNotFound());
                }
                var model = new EditCustomerAccountViewModel();
                model.Id          = act.ID;
                model.AccountName = act.AccountName;
                model.BranchId    = act.BranchId;

                ViewBag.BranchId = new SelectList(branchRepo.GetAll(), "ID", "Name", model.BranchId);
                return(View(model));
            }
            catch (Exception ex)
            {
                //ErrorLogger.Log("Message= " + ex.Message + "\nInner Exception= " + ex.InnerException + "\n");
                return(PartialView("Error"));
            }
        }
예제 #2
0
        public ActionResult EditAccount(EditCustomerAccountViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var account = actRepo.GetById(model.Id);
                    account.AccountName = model.AccountName;
                    account.BranchId    = model.BranchId;
                    actRepo.Update(account);

                    return(RedirectToAction("Index"));
                }

                ViewBag.BranchId = new SelectList(branchRepo.GetAll(), "ID", "Name", model.BranchId);
                return(View(model));
            }
            catch (Exception)
            {
                //ErrorLogger.Log("Message= " + ex.Message + "\nInner Exception= " + ex.InnerException + "\n");
                return(PartialView("Error"));
            }
        }//end Edit