public GeneralResponse AddMoneyAccountEmployee(AddMoneyAccountEmployeeRequest request, Guid CreateEmployeeID) { GeneralResponse response = new GeneralResponse(); try { MoneyAccountEmployee moneyAccountEmployee = new MoneyAccountEmployee(); moneyAccountEmployee.CreateDate = PersianDateTime.Now; moneyAccountEmployee.CreateEmployee = _employeeRepository.FindBy(CreateEmployeeID); moneyAccountEmployee.Employee = _employeeRepository.FindBy(request.EmployeeID); moneyAccountEmployee.MoneyAccount = _moneyAccountRepository.FindBy(request.MoneyAccountID); _moneyAccountEmployeeRepository.Add(moneyAccountEmployee); _uow.Commit(); } catch (Exception ex) { response.ErrorMessages.Add(ex.Message); if (ex.InnerException != null) { response.ErrorMessages.Add(ex.InnerException.Message); } } return(response); }
public GeneralResponse EditMoneyAccount(EditMoneyAccountRequestOld request) { GeneralResponse response = new GeneralResponse(); MoneyAccount moneyAccount = new MoneyAccount(); moneyAccount = _moneyAccountRepository.FindBy(request.ID); if (moneyAccount != null) { try { moneyAccount.ModifiedDate = PersianDateTime.Now; moneyAccount.ModifiedEmployee = _employeeRepository.FindBy(request.ModifiedEmployeeID); 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; if (moneyAccount.RowVersion != request.RowVersion) { response.ErrorMessages.Add("کارشناس محترم، یک کاربر همزمان با شما در حال ویرایش این رکورد است. بنابراین اطلاعات شما ذخیره نمی شود."); return(response); } else { moneyAccount.RowVersion += 1; } if (moneyAccount.GetBrokenRules().Count() > 0) { foreach (BusinessRule businessRule in moneyAccount.GetBrokenRules()) { response.ErrorMessages.Add(businessRule.Rule); } return(response); } _moneyAccountRepository.Save(moneyAccount); _uow.Commit(); ////response.success = true; } catch (Exception ex) { response.ErrorMessages.Add(ex.Message); } } else { response.ErrorMessages.Add("هیچ موردی جهت ویرایش وجود ندارد."); } return(response); }
public GeneralResponse AddFiscal(AddFiscalRequest request) { GeneralResponse response = new GeneralResponse(); try { Fiscal fiscal = new Fiscal(); fiscal.ID = Guid.NewGuid(); fiscal.CreateDate = PersianDateTime.Now; fiscal.CreateEmployee = _employeeRepository.FindBy(request.CreateEmployeeID); fiscal.Cost = request.Cost; if (request.CustomerID != null && request.CustomerID != Guid.Empty) { fiscal.Customer = this._customerRepository.FindBy(request.CustomerID); } else if (request.Phone != null) { fiscal.Customer = _customerRepository.FindByPhoneCode(request.Phone).First(); } fiscal.DocumentSerial = request.DocumentSerial; fiscal.DocumentType = request.DocumentType; fiscal.Note = request.Note; fiscal.MoneyAccount = _moneyAccountRepository.FindBy(request.MoneyAccountID); fiscal.InvestDate = request.InvestDate; fiscal.Confirm = ConfirmEnum.NotChecked; fiscal.ChargeStatus = ChargeStatus.NotChecked; fiscal.ForCharge = request.ForCharge; fiscal.FollowNumber = NewFollowNumber; fiscal.RowVersion = 1; #region Validation if (fiscal.GetBrokenRules().Count() > 0) { foreach (BusinessRule businessRule in fiscal.GetBrokenRules()) { response.ErrorMessages.Add(businessRule.Rule); } return(response); } #endregion _fiscalRepository.Add(fiscal); _uow.Commit(); // for retriving FollowNumber response.ObjectAdded = _fiscalRepository.FindBy(fiscal.ID).ConvertToFiscalView(); } catch (Exception ex) { response.ErrorMessages.Add(ex.Message); if (ex.InnerException != null) { response.ErrorMessages.Add(ex.InnerException.Message); if (ex.InnerException.InnerException != null) { response.ErrorMessages.Add(ex.InnerException.InnerException.Message); } } } return(response); }