public GeneralResponse DeleteMoneyAccountEmployee(IEnumerable <DeleteMoneyAccountEmployeeRequest> requests, Guid MoneyAccountID) { GeneralResponse response = new GeneralResponse(); try { foreach (DeleteMoneyAccountEmployeeRequest request in requests) { Query query = new Query(); Criterion criteriaEmployeeID = new Criterion("Employee.ID", request.EmployeeID, CriteriaOperator.Equal); query.Add(criteriaEmployeeID); Criterion criteriaMoneyAccountID = new Criterion("MoneyAccount.ID", MoneyAccountID, CriteriaOperator.Equal); query.Add(criteriaMoneyAccountID); MoneyAccountEmployee moneyAccounEmployee = _moneyAccountEmployeeRepository.FindBy(query).FirstOrDefault(); _moneyAccountEmployeeRepository.Remove(moneyAccounEmployee); } _uow.Commit(); } catch (Exception ex) { response.ErrorMessages.Add(ex.Message); if (ex.InnerException != null) { response.ErrorMessages.Add(ex.InnerException.Message); } } return(response); }
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 DeleteMoneyAccountEmployee(Guid moneyAccountID, Guid employeeID) { GeneralResponse response = new GeneralResponse(); Infrastructure.Querying.Query moneyAccount = new Infrastructure.Querying.Query(); Criterion criteria1 = new Criterion("MoneyAccount.ID", moneyAccountID, CriteriaOperator.Equal); Criterion criteria2 = new Criterion("Employee.ID", employeeID, CriteriaOperator.Equal); moneyAccount.Add(criteria1); moneyAccount.Add(criteria2); MoneyAccountEmployee moneyAccountEmployee = _moneyAccountEmployeeRepository.FindBy(moneyAccount).FirstOrDefault(); if (moneyAccountEmployee != null) { try { _moneyAccountEmployeeRepository.Remove(moneyAccountEmployee); _uow.Commit(); ////response.success = true; } catch (Exception ex) { response.ErrorMessages.Add(ex.Message); } } return(response); }
public GeneralResponse DeleteMoneyAccountEmployee(DeleteRequest request) { GeneralResponse response = new GeneralResponse(); MoneyAccountEmployee moneyAccountEmployee = new MoneyAccountEmployee(); moneyAccountEmployee = _moneyAccountEmployeeRepository.FindBy(request.ID); if (moneyAccountEmployee != null) { try { _moneyAccountEmployeeRepository.Remove(moneyAccountEmployee); _uow.Commit(); ////response.success = true; } catch (Exception ex) { response.ErrorMessages.Add(ex.Message); } } return(response); }
public GeneralResponse EditMoneyAccountEmployee(EditMoneyAccountEmployeeRequest request) { GeneralResponse response = new GeneralResponse(); MoneyAccountEmployee moneyAccountEmployee = new MoneyAccountEmployee(); moneyAccountEmployee = _moneyAccountEmployeeRepository.FindBy(request.ID); if (moneyAccountEmployee != null) { try { moneyAccountEmployee.ModifiedDate = PersianDateTime.Now; moneyAccountEmployee.ModifiedEmployee = _employeeRepository.FindBy(request.ModifiedEmployeeID); if (request.EmployeeID != null) { moneyAccountEmployee.Employee = this._employeeRepository.FindBy(request.EmployeeID); } if (request.MoneyAccountID != null) { moneyAccountEmployee.MoneyAccount = this._moneyAccountRepository.FindBy(request.MoneyAccountID); } if (moneyAccountEmployee.RowVersion != request.RowVersion) { response.ErrorMessages.Add("EditConcurrencyKey"); return(response); } else { moneyAccountEmployee.RowVersion += 1; } if (moneyAccountEmployee.GetBrokenRules().Count() > 0) { foreach (BusinessRule businessRule in moneyAccountEmployee.GetBrokenRules()) { response.ErrorMessages.Add(businessRule.Rule); } return(response); } _moneyAccountEmployeeRepository.Save(moneyAccountEmployee); _uow.Commit(); ////response.success = true; } catch (Exception ex) { response.ErrorMessages.Add(ex.Message); } } else { response.ErrorMessages.Add("NoItemToEditKey"); } return(response); }
public GeneralResponse AddMoneyAccountEmployee(AddMoneyAccountEmployeeRequestOld request) { GeneralResponse response = new GeneralResponse(); try { MoneyAccountEmployee moneyAccountEmployee = new MoneyAccountEmployee(); moneyAccountEmployee.ID = Guid.NewGuid(); moneyAccountEmployee.CreateDate = PersianDateTime.Now; moneyAccountEmployee.CreateEmployee = _employeeRepository.FindBy(request.CreateEmployeeID); moneyAccountEmployee.Employee = this._employeeRepository.FindBy(request.EmployeeID); moneyAccountEmployee.MoneyAccount = this._moneyAccountRepository.FindBy(request.MoneyAccountID); moneyAccountEmployee.RowVersion = 1; #region Validation if (moneyAccountEmployee.GetBrokenRules().Count() > 0) { foreach (BusinessRule businessRule in moneyAccountEmployee.GetBrokenRules()) { response.ErrorMessages.Add(businessRule.Rule); } return(response); } #endregion _moneyAccountEmployeeRepository.Add(moneyAccountEmployee); _uow.Commit(); ////response.success = true; } catch (Exception ex) { response.ErrorMessages.Add(ex.Message); } return(response); }
public GetMoneyAccountEmployeeResponse GetMoneyAccountEmployee(GetRequest request) { GetMoneyAccountEmployeeResponse response = new GetMoneyAccountEmployeeResponse(); try { MoneyAccountEmployee moneyAccountEmployee = new MoneyAccountEmployee(); MoneyAccountEmployeeView moneyAccountEmployeeView = moneyAccountEmployee.ConvertToMoneyAccountEmployeeView(); moneyAccountEmployee = _moneyAccountEmployeeRepository.FindBy(request.ID); if (moneyAccountEmployee != null) { moneyAccountEmployeeView = moneyAccountEmployee.ConvertToMoneyAccountEmployeeView(); } response.MoneyAccountEmployeeView = moneyAccountEmployeeView; } catch (Exception ex) { } return(response); }
public static MoneyAccountEmployeeView ConvertToMoneyAccountEmployeeView(this MoneyAccountEmployee moneyAccountEmployee) { return(Mapper.Map <MoneyAccountEmployee, MoneyAccountEmployeeView>(moneyAccountEmployee)); }