示例#1
0
        public GeneralResponse EditQueryEmployee(EditQueryEmployeeRequest request)
        {
            GeneralResponse response      = new GeneralResponse();
            QueryEmployee   queryEmployee = new QueryEmployee();

            queryEmployee = _queryEmployeeRepository.FindBy(request.ID);

            if (queryEmployee != null)
            {
                try
                {
                    queryEmployee.ModifiedDate     = PersianDateTime.Now;
                    queryEmployee.ModifiedEmployee = _employeeRepository.FindBy(request.ModifiedEmployeeID);
                    if (request.EmployeeID != null)
                    {
                        queryEmployee.Employee = this._employeeRepository.FindBy(request.EmployeeID);
                    }
                    if (request.QueryID != null)
                    {
                        queryEmployee.Query = this._queryRepository.FindBy(request.QueryID);
                    }

                    if (queryEmployee.RowVersion != request.RowVersion)
                    {
                        response.ErrorMessages.Add("EditConcurrencyKey");
                        return(response);
                    }
                    else
                    {
                        queryEmployee.RowVersion += 1;
                    }

                    if (queryEmployee.GetBrokenRules().Count() > 0)
                    {
                        foreach (BusinessRule businessRule in queryEmployee.GetBrokenRules())
                        {
                            response.ErrorMessages.Add(businessRule.Rule);
                        }

                        return(response);
                    }

                    _queryEmployeeRepository.Save(queryEmployee);
                    _uow.Commit();

                    ////response.success = true;
                }
                catch (Exception ex)
                {
                    response.ErrorMessages.Add(ex.Message);
                }
            }
            else
            {
                response.ErrorMessages.Add("NoItemToEditKey");
            }
            return(response);
        }
示例#2
0
        public GeneralResponse AddQueryEmployee(AddQueryEmployeeRequestOld request)
        {
            GeneralResponse response = new GeneralResponse();

            try
            {
                QueryEmployee queryEmployee = new QueryEmployee();
                queryEmployee.CreateEmployee = _employeeRepository.FindBy(request.CreateEmployeeID);
                queryEmployee.Employee       = this._employeeRepository.FindBy(request.EmployeeID);
                queryEmployee.Query          = this._queryRepository.FindBy(request.QueryID);

                #region Validation

                if (queryEmployee.GetBrokenRules().Count() > 0)
                {
                    foreach (BusinessRule businessRule in queryEmployee.GetBrokenRules())
                    {
                        response.ErrorMessages.Add(businessRule.Rule);
                    }

                    return(response);
                }

                #endregion

                _queryEmployeeRepository.Add(queryEmployee);
                _uow.Commit();

                ////response.success = true;
            }
            catch (Exception ex)
            {
                response.ErrorMessages.Add(ex.Message);
            }

            return(response);
        }