public async Task <ActionResult <List <Category> > > Get([FromServices] BooksApiContext booksApiContext)
        {
            try
            {
                Service = new CategoryService(booksApiContext);

                return(await Service.GetCategoriesAsync());
            }
            catch (Exception e)
            {
                return(BadRequest(new { status = "error", message = e.Message }));
            }
        }
        public async Task <ActionResult <Category> > Post([FromServices] BooksApiContext booksApiContext, [FromBody] Category category)
        {
            try
            {
                Service = new CategoryService(booksApiContext);

                if (ModelState.IsValid)
                {
                    return(await Service.PostAsync(category));
                }
                else
                {
                    return(BadRequest(ModelState));
                }
            }
            catch (Exception e)
            {
                return(BadRequest(new { status = "error", message = e.Message, detail = e.InnerException.Message }));
            }
        }
示例#3
0
 public PublishersController(BooksApiContext context)
 {
     _context = context;
 }
示例#4
0
 public GenericRepository(BooksApiContext context)
 {
     _context = context;
     _dbSet   = _context.Set <TEntity>();
 }
 public CategoryService(BooksApiContext context)
 {
     _Context = context;
 }
示例#6
0
 public BooksController(BooksApiContext context)
 {
     _context = context;
 }
示例#7
0
 public UserService(BooksApiContext context)
 {
     _Context = context;
 }
示例#8
0
 public UnitOfWork(BooksApiContext context)
 {
     _context = context;
 }