Beispiel #1
0
        public async Task InsertAsync(ChurrascoPost churrascoPost)
        {
            if (churrascoPost == null || churrascoPost.Data < DateTime.Today)
            {
                throw new ArgumentException("Churrasco inválido");
            }

            try
            {
                var churrasco = new Churrasco
                {
                    Data           = churrascoPost.Data,
                    Descricao      = churrascoPost.Descricao,
                    ObsAdicional   = churrascoPost.ObsAdicional,
                    ValorComBebida = churrascoPost.ValorComBebida,
                    ValorSemBebida = churrascoPost.ValorSemBebida,
                };
                _context.Add(churrasco);
                await _context.SaveChangesAsync();
            }
            catch (DBConcurrencyException e)
            {
                throw new DBConcurrencyException(e.Message);
            }
        }
Beispiel #2
0
        public async Task <IActionResult> Create(ChurrascoPost churrascoPost)
        {
            await _churrascoService.InsertAsync(churrascoPost);

            return(Ok("Churrasco Criado"));
        }