Beispiel #1
0
        public CommandResult Criar(CriarMaterialCommand command)
        {
            try
            {
                command.Validate();
                if (command.Invalid)
                {
                    return(CommandResult.Invalid(command.Notifications.ToNotificationsString()));
                }

                Material material = Material.Criar(DataString.FromString(command.Descricao),
                                                   DataString.FromNullableString(command.Volume),
                                                   DataString.FromNullableString(command.Material_Coletado),
                                                   DataString.FromNullableString(command.Material_Coletado));

                dataContext.Add(material);
                dataContext.SaveChanges();

                return(CommandResult.Valid());
            }
            catch (Exception ex)
            {
                return(CommandResult.Invalid(ex.Message));
            }
        }
 public IActionResult Criar(
     [FromServices] IMaterialService service,
     [FromBody] CriarMaterialCommand command)
 {
     return(Result(service.Criar(command)));
 }