public GeneralResponse AddNetworkCredit(AddNetworkCreditRequest request, Guid CreateEmployeeID) { GeneralResponse response = new GeneralResponse(); try { NetworkCredit networkCredit = new NetworkCredit(); networkCredit.ID = Guid.NewGuid(); networkCredit.CreateDate = PersianDateTime.Now; networkCredit.CreateEmployee = _employeeRepository.FindBy(CreateEmployeeID); if (request.Type) { networkCredit.Amount = request.Amount; } else { networkCredit.Amount = -request.Amount; } networkCredit.FromAccount = this._moneyAccountRepository.FindBy(request.FromAccountID); networkCredit.InvestDate = request.InvestDate; networkCredit.Network = this._networkRepository.FindBy(request.NetworkID); networkCredit.Note = request.Note; networkCredit.ToAccount = request.ToAccount; networkCredit.TransactionNo = request.TransactionNo; networkCredit.RowVersion = 1; networkCredit.Balance += networkCredit.Network.Balance + networkCredit.Amount; _networkCreditRepository.Add(networkCredit); Network network = networkCredit.Network; network.Balance += request.Amount; _networkRepository.Save(network); _uow.Commit(); ////response.success = true; // Validation if (networkCredit.GetBrokenRules().Count() > 0) { foreach (BusinessRule businessRule in networkCredit.GetBrokenRules()) { response.ErrorMessages.Add(businessRule.Rule); } return(response); } } catch (Exception ex) { response.ErrorMessages.Add(ex.Message); } return(response); }
public JsonResult NetworkCredit_Insert(AddNetworkCreditRequest request) { GeneralResponse response = new GeneralResponse(); #region Access Check bool hasPermission = GetEmployee().IsGuaranteed("Network_Insert"); if (!hasPermission) { response.ErrorMessages.Add("AccessDenied"); return(Json(response, JsonRequestBehavior.AllowGet)); } #endregion response = _networkCreditService.AddNetworkCredit(request, GetEmployee().ID); return(Json(response, JsonRequestBehavior.AllowGet)); }