Ejemplo n.º 1
0
        public async Task <ActionResult <FreteViewModel> > AdicionarModalidade([FromBody] FreteViewModel command)
        {
            command.Check();
            if (!command.IsValid())
            {
                return(BadRequest(command.Errors));
            }

            if (await _context.Fretes.AnyAsync(a => a.Modalidade.ToUpper().Equals(command.Modalidade.Trim().ToUpper())))
            {
                command.SetError("Modalidade já existe");
                return(BadRequest(command.Errors));
            }


            var frete = command.ToEntity();
            await _context.Fretes.AddAsync(frete);

            return(Created(nameof(ObterModalidades), command));
        }
Ejemplo n.º 2
0
 public frmFreteLista()
 {
     InitializeComponent();
     BindingContext = viewModel = new FreteViewModel();
     VerificaUser();
 }