Exemple #1
0
        public IServiceActionResult CreateTipoInsumo(TipoInsumoEntity tipoInsumoEntity)
        {
            tipoInsumoEntity.Validate();

            if (tipoInsumoEntity.Invalid)
            {
                return(new ServiceActionResult(false, "Algo deu errado ao incluir!", tipoInsumoEntity.Notifications));
            }

            var tipoInsumoNew = new TipoInsumoEntity
                                (
                tipoInsumoEntity.descricao_tp_insumo,
                // tipoInsumoEntity.qtd_dias_manut_prev, //validar essa data!!!! pq o tipo do insumo define os dias de manut do insumo?
                DateTime.Now,
                tipoInsumoEntity.user
                                );

            _tipoInsumoRepository.Create(tipoInsumoNew);


            var tipoInsumo = _tipoInsumoRepository.GetById(tipoInsumoNew.Id);

            if (tipoInsumo == null)
            {
                return(new ServiceActionResult(false, "Algo deu errado ao incluir!", null));
            }

            return(new ServiceActionResult(true, "Tipo de Insumo criado!", tipoInsumo));
        }
Exemple #2
0
 public TipoInsumoEntity GetById(
     Guid id,
     [FromServices] ITipoInsumoRepository repository
     )
 {
     return(repository.GetById(id));
 }