Beispiel #1
0
        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." }));
            }
        }
Beispiel #2
0
 public UserController([FromServices] DataContextShopDTO context)
 {
     _context = context;
 }
Beispiel #3
0
 public CategoryController([FromServices] DataContextShopDTO context)
 {
     _context = context;
 }
 public ProductController([FromServices] DataContextShopDTO context)
 {
     _context = context;
 }