示例#1
0
        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);
        }
示例#2
0
 public IActionResult Post(int problemId, [FromBody] CreateTagDto value)
 {
     if (ModelState.IsValid)
     {
         var result = _tagService.AddProblemTag(value, problemId);
         if (result != null)
         {
             return(Ok(result));
         }
     }
     return(BadRequest());
 }