public DatabaseResult Add(CreateProblem createProblem) { var databaseResult = new DatabaseResult { Success = false }; var result = _problemRepository.Add(createProblem); if (result != 0) { databaseResult.Key = result; databaseResult.Success = true; if (createProblem.Tags != null && createProblem.Tags.Any()) { var tags = createProblem.Tags.Select(x => new CreateTagDto { Name = x }); foreach (var createTagDto in tags) { _tagRepository.AddProblemTag(createTagDto, result); } } if (!string.IsNullOrEmpty(createProblem.AssignedUser)) { _notificationService.SendNotification(createProblem.AssignedUser, result, $"Jums priskirta problema: {createProblem.Name}"); } } return(databaseResult); }
public GeneralResponse AddProblem(AddProblemRequest request) { GeneralResponse response = new GeneralResponse(); try { // چک کردن اینکه آیا در این مرحله امکان افزودن مشکل وجود دارد یا خیر Customer customer = this._customerRepository.FindBy(request.CustomerID); Level level = _levelRepository.FindBy(customer.Level.ID); if (level.Options == null || !level.Options.CanAddProblem) { response.ErrorMessages.Add("ProblemIsNotPermitedInThisLevel"); return(response); } Problem problem = new Problem(); problem.ID = Guid.NewGuid(); problem.CreateDate = PersianDateTime.Now; problem.CreateEmployee = _employeeRepository.FindBy(request.CreateEmployeeID); problem.Customer = this._customerRepository.FindBy(request.CustomerID); problem.Priority = request.Priority; problem.ProblemDescription = request.ProblemDescription; problem.ProblemTitle = request.ProblemTitle; problem.State = request.State; problem.RowVersion = 1; _problemRepository.Add(problem); _uow.Commit(); ////response.success = true; // Validation if (problem.GetBrokenRules().Count() > 0) { foreach (BusinessRule businessRule in problem.GetBrokenRules()) { response.ErrorMessages.Add(businessRule.Rule); } return(response); } } catch (Exception ex) { response.ErrorMessages.Add(ex.Message); } return(response); }
public void AddProblem(Problem newProblem, ObservableCollection <Device> devicesOfCurrentProblem) { _problemRepository.Add(newProblem, devicesOfCurrentProblem); //conn.AddProblem(newProblem, DevicesOfCurrentProblem); }