Пример #1
0
        public FindingsStatesOutput Execute(int id)
        {
            var paramC = _findingsStatesRepository.Get(id);

            if (paramC != null)
            {
                return(new FindingsStatesOutput(paramC.Id, paramC.Code, paramC.Name, paramC.Colour, paramC.Active));
            }

            throw new EntityNotFoundException(id, "No se encontró un estado de hallazgo con ese ID");
        }
 public FindingsStatesOutput Execute(string code, string name, string colour, bool active)
 {
     if (_findingsStatesRepository.Get(code, name, colour) == null)
     {
         var newParam = new Domain.FindingsState.FindingsState(code, name, colour, active);
         newParam = _findingsStatesRepository.Add(newParam);
         return(new FindingsStatesOutput(newParam.Id, newParam.Code, newParam.Name, newParam.Colour, newParam.Active));
     }
     else
     {
         throw new DuplicateEntityException(name, "Ya existe un estado de hallazgo con este nombre, código o color");
     }
 }
        public FindingsStatesOutput Execute(int id, string code, string name, string colour, bool active)
        {
            var findinS = _findingsStatesRepository.Get(id);

            if (findinS != null)
            {
                if (_findingsStatesRepository.CheckExistsFindingState(code, name, colour, id) == null)
                {
                    findinS.Name   = name;
                    findinS.Colour = colour;
                    findinS.Code   = code;
                    findinS.Active = active;
                    var res = _findingsStatesRepository.Update(findinS);

                    return(new FindingsStatesOutput(findinS.Id, findinS.Code, findinS.Name, findinS.Colour, findinS.Active));
                }
                else
                {
                    throw new DuplicateEntityException(name, "Ya existe un estado de hallazgo con este nombre, codigo o color");
                }
            }
            throw new EntityNotFoundException(id, "No se encontró un estado de hallazgo con ese ID");
        }