コード例 #1
0
        public async Task <ActionResult <Investimentos> > PostInvestimentos(InvestimentosApi model)
        {
            if (ModelState.IsValid)
            {
                await _context.InsertAsync(model.ToModel());

                return(Ok());
            }

            return(BadRequest());
        }
コード例 #2
0
 public static Investimentos ToModel(this InvestimentosApi model)
 {
     return(new Investimentos
     {
         Id = model.Id,
         NomeInvestimento = model.NomeInvestimento,
         ValorInvestido = model.ValorInvestido,
         Rendimento = model.Rendimento,
         DataInvestimento = Convert.ToDateTime(model.DataInvestimento),
     });
 }
コード例 #3
0
        public async Task <IActionResult> PutInvestimentos(InvestimentosApi model)
        {
            if (ModelState.IsValid)
            {
                await _context.UpdateChangesAsync(model.ToModel());

                return(Ok());
            }

            return(BadRequest());
        }