コード例 #1
0
        public Indication ChangeIndicationStatus(int indicationId, IndicationStatus newStatus)
        {
            if (indicationId == 0)
            {
                throw new BadRequestException("Algo deu errado, atualize a página ou entre em contato com suporte!");
            }

            Indication indication = new Indication();

            try
            {
                indication = _repository.GetById(indicationId);
            } catch (Exception e)
            {
                throw new Exception($"Algo deu errado: {e}");
            }

            if (indication == null)
            {
                throw new NotFoundException("Nenhuma indicação encontrada!");
            }

            if (indication.Status.Equals(newStatus))
            {
                throw new BadRequestException("Esta indicação já está nessa etapa!");
            }

            indication.Status = newStatus;

            try
            {
                _repository.Update(indication);
                return(indication);
            } catch (Exception e)
            {
                throw new Exception($"Algo deu errado: {e}");
            }
        }
コード例 #2
0
 public Indication ChangeIndicationStatus([FromHeader] IndicationStatus status, int indicationId)
 {
     return(_service.ChangeIndicationStatus(indicationId, status));
 }