public GeneralResponse EditLeadTitleTemplate(IEnumerable <EditLeadTitleTemplateRequest> requests, Guid employeeID) { GeneralResponse response = new GeneralResponse(); try { foreach (var request in requests) { LeadTitleTemplate leadTitleTemplate = _leadTitleTemplateRepository.FindBy(request.ID); leadTitleTemplate.ModifiedDate = PersianDateTime.Now; leadTitleTemplate.ModifiedEmployee = _employeeRepository.FindBy(employeeID); leadTitleTemplate.Description = request.Description; leadTitleTemplate.Group = _groupRepository.FindBy(request.GroupID); leadTitleTemplate.Title = request.Title; #region RowVersion - Validation if (leadTitleTemplate.RowVersion != request.RowVersion) { response.ErrorMessages.Add("EditConcurrencyKey"); return(response); } else { leadTitleTemplate.RowVersion += 1; } if (leadTitleTemplate.GetBrokenRules().Count() > 0) { foreach (BusinessRule businessRule in leadTitleTemplate.GetBrokenRules()) { response.ErrorMessages.Add(businessRule.Rule); } return(response); } #endregion _leadTitleTemplateRepository.Save(leadTitleTemplate); } _uow.Commit(); } catch (Exception ex) { response.ErrorMessages.Add(ex.Message); if (ex.InnerException != null) { response.ErrorMessages.Add(ex.InnerException.Message); } } return(response); }
public GeneralResponse AddNegotiation(AddNegotiationRequest request, Guid EmployeeID) { GeneralResponse response = new GeneralResponse(); try { Negotiation negotiation = new Negotiation(); negotiation.ID = Guid.NewGuid(); negotiation.CreateDate = PersianDateTime.Now; negotiation.CreateEmployee = _employeeRepository.FindBy(EmployeeID); negotiation.RowVersion = 1; negotiation.Customer = _customerRepository.FindBy(request.CustomerID); negotiation.LeadTitleTemplate = _leadTitleTemplateRepository.FindBy(request.LeadTitleTemplateID); negotiation.NegotiationDate = request.NegotiationDate; negotiation.NegotiationTime = request.NegotiationTime; negotiation.RememberTime = request.RememberTime; negotiation.SendSms = request.SendSms != null && (bool)request.SendSms; negotiation.ReferedEmployee = request.ReferedEmployeeID == null ? _employeeRepository.FindBy(EmployeeID) : _employeeRepository.FindBy((Guid)request.ReferedEmployeeID); negotiation.NegotiationDesciption = request.NegotiationDesciption; _negotiationRepository.Add(negotiation); _uow.Commit(); } catch (Exception ex) { response.ErrorMessages.Add(ex.Message); if (ex.InnerException != null) { response.ErrorMessages.Add(ex.InnerException.Message); } } return(response); }