public async Task <ActionResult <Category> > PostCategory( [FromBody] Category category, [FromServices] DataContextShopDTO dataContext) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { _context.Categories.Add(category); await _context.SaveChangesAsync(); return(Ok(category)); } catch { return(BadRequest(new { message = "Não foi possível criar a categoria." })); } }
public UserController([FromServices] DataContextShopDTO context) { _context = context; }
public CategoryController([FromServices] DataContextShopDTO context) { _context = context; }
public ProductController([FromServices] DataContextShopDTO context) { _context = context; }