public ActionResult Create(MoneyAccountDetailView moneyAccountDetailView) { moneyAccountDetailView.EmployeeView = GetEmployee(); #region Check Access bool hasPermission = GetEmployee().IsGuaranteed("MoneyAccount_Insert"); if (!hasPermission) { ModelState.AddModelError("", "AccessDenied"); return(View(moneyAccountDetailView)); } #endregion if (ModelState.IsValid) { try { AddMoneyAccountRequestOld request = new AddMoneyAccountRequestOld(); request.CreateEmployeeID = GetEmployee().ID; request.AccountName = moneyAccountDetailView.MoneyAccountView.AccountName; request.BAccountInfo = moneyAccountDetailView.MoneyAccountView.BAccountInfo; request.BAccountNumber = moneyAccountDetailView.MoneyAccountView.BAccountNumber; request.IsBankAccount = moneyAccountDetailView.MoneyAccountView.IsBankAccount; request.Pay = moneyAccountDetailView.MoneyAccountView.Pay; request.Receipt = moneyAccountDetailView.MoneyAccountView.Receipt; GeneralResponse response = this._moneyAccountService.AddMoneyAccount(request); if (response.success) { return(RedirectToAction("Index")); } else { foreach (string error in response.ErrorMessages) { ModelState.AddModelError("", error); } return(View(moneyAccountDetailView)); } } catch (Exception ex) { ModelState.AddModelError("", ex.Message); return(View(moneyAccountDetailView)); } } return(View(moneyAccountDetailView)); }
public GeneralResponse AddMoneyAccount(AddMoneyAccountRequestOld request) { GeneralResponse response = new GeneralResponse(); try { MoneyAccount moneyAccount = new MoneyAccount(); moneyAccount.ID = Guid.NewGuid(); moneyAccount.CreateDate = PersianDateTime.Now; moneyAccount.CreateEmployee = _employeeRepository.FindBy(request.CreateEmployeeID); moneyAccount.AccountName = request.AccountName; moneyAccount.BAccountInfo = request.BAccountInfo; moneyAccount.BAccountNumber = request.BAccountNumber; moneyAccount.IsBankAccount = request.IsBankAccount; moneyAccount.Pay = request.Pay; moneyAccount.Receipt = request.Receipt; moneyAccount.Discontinued = request.Discontinued; moneyAccount.RowVersion = 1; _moneyAccountRepository.Add(moneyAccount); _uow.Commit(); ////response.success = true; // Validation if (moneyAccount.GetBrokenRules().Count() > 0) { foreach (BusinessRule businessRule in moneyAccount.GetBrokenRules()) { response.ErrorMessages.Add(businessRule.Rule); } return(response); } } catch (Exception ex) { response.ErrorMessages.Add(ex.Message); } return(response); }