예제 #1
0
        public GeneralResponse EditLeadResultTemplate(IEnumerable <EditLeadResultTemplateRequest> requests,
                                                      Guid EmployeeID)
        {
            GeneralResponse response = new GeneralResponse();

            try
            {
                foreach (var request in requests)
                {
                    LeadResultTemplate leadresTitleTemplate = _leadResultTemplateRepository.FindBy(request.ID);
                    leadresTitleTemplate.LeadResulTitle = request.LeadResulTitle;
                    leadresTitleTemplate.Description    = request.Description;
                    leadresTitleTemplate.Group          = _groupRepository.FindBy(request.GroupID);

                    #region RowVersion - Validation
                    if (leadresTitleTemplate.RowVersion != request.RowVersion)
                    {
                        response.ErrorMessages.Add("EditConcurrencyKey");
                        return(response);
                    }
                    else
                    {
                        leadresTitleTemplate.RowVersion += 1;
                    }

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

                        return(response);
                    }

                    #endregion

                    _leadResultTemplateRepository.Save(leadresTitleTemplate);
                    _uow.Commit();
                }
            }
            catch (Exception ex)
            {
                response.ErrorMessages.Add(ex.Message);
                if (ex.InnerException != null)
                {
                    response.ErrorMessages.Add(ex.InnerException.Message);
                }
            }

            return(response);
        }
예제 #2
0
        public GeneralResponse AddLeadResultTemplate(IEnumerable <AddLeadResultTemplateRequest> requests, Guid EmployeeID)
        {
            GeneralResponse response = new GeneralResponse();

            try
            {
                foreach (var request in requests)
                {
                    LeadResultTemplate leadResultTemplate = new LeadResultTemplate();
                    leadResultTemplate.ID             = Guid.NewGuid();
                    leadResultTemplate.CreateDate     = PersianDateTime.Now;
                    leadResultTemplate.CreateEmployee = _employeerepository.FindBy(EmployeeID);
                    leadResultTemplate.LeadResulTitle = request.LeadResulTitle;
                    leadResultTemplate.Description    = request.Description;
                    leadResultTemplate.Group          = _groupRepository.FindBy(request.GroupID);
                    leadResultTemplate.RowVersion     = 1;
                    // Validation
                    if (leadResultTemplate.GetBrokenRules().Any())
                    {
                        foreach (BusinessRule businessRule in leadResultTemplate.GetBrokenRules())
                        {
                            response.ErrorMessages.Add(businessRule.Rule);
                        }

                        return(response);
                    }
                    _leadResultTemplateRepository.Add(leadResultTemplate);
                    _uow.Commit();
                }
            }
            catch (Exception ex)
            {
                response.ErrorMessages.Add(ex.Message);
                if (ex.InnerException != null)
                {
                    response.ErrorMessages.Add(ex.InnerException.Message);
                }
            }

            return(response);
        }