public ResultViewModel AddAction(int id, AddActionViewModel request)
        {
            var nonconformity = _nonconformityRepository.GetById(id);

            if (nonconformity == null)
            {
                return(new ResultViewModel(false, id, "Nonconformity does not exist!"));
            }
            Action           action           = new Action(id, request.Description);
            ValidationResult validationResult = action.isValid();

            if (!validationResult.IsValid)
            {
                return(new ResultViewModel(false, action.Id, validationResult.ToString()));
            }
            _nonconformityRepository.AddActionToNonconformity(id, action);
            _actionRepository.Add(action);
            return(new ResultViewModel(true, nonconformity.Id, "Action successfully added!"));
        }
示例#2
0
 public IActionResult AddAction(Models.Action action)
 {
     _actionRepository.Add(action);
     return(CreatedAtAction("Get", new { id = action.Id }, action));
 }