コード例 #1
0
 public ActionResult Create(AccountType accounttype)
 {
     if (ModelState.IsValid)
     {
         accountTypeRepository.InsertOrUpdate(accounttype);
         accountTypeRepository.Save();
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View());
     }
 }
コード例 #2
0
        public void RegisterAccountType(CreateAccountTypeDto dto)
        {
            uow.Begin();
            var accountType = new AccountType(dto.AccountTypeNumber, dto.Title);

            try
            {
                accountTypeRepository.Save(accountType);
                uow.Commit();
            }
            catch (System.Exception ex)
            {
                uow.Rollback();
            }
        }
コード例 #3
0
        public void Handle(RegisterAccountTypeCommand command)
        {
            uow.Begin();

            var accounttype = new AccountType(command.AccountTypeNumber, command.Title);

            try
            {
                accountTypeRepository.Save(accounttype);
                uow.Commit();
            }
            catch (System.Exception ex)
            {
                uow.Rollback();
            }
        }
コード例 #4
0
        public IActionResult EditAccountType(AccountType model)
        {
            if (ModelState.IsValid)
            {
                _accountTypeRepo.Save(model);
                TempData["message"] = $"{model.Name} has been saved";
                return(RedirectToAction("AccountTypes"));
            }
            else
            {
                if (model.ID == 0)
                {
                    ViewBag.FormTitle = "Create Account Type";
                }
                else
                {
                    ViewBag.FormTitle = "Edit Account Type";
                }

                return(View(model));
            }
        }