Пример #1
0
        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 }));
            }
        }
Пример #2
0
        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>();
 }
Пример #5
0
 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;
 }