public async Task <ActionResult <CreateTodoHybridDto> > PostAsync(CreateTodoHybridDto item, [FromServices] ICrudServicesAsync service)
        {
            var result = await service.CreateAndSaveAsync(item);

            //NOTE: to get this to work you MUST set the name of the HttpGet, e.g. [HttpGet("{id}", Name= "GetSingleTodo")],
            //on the Get you want to call, then then use the Name value in the Response.
            //Otherwise you get a "No route matches the supplied values" error.
            //see https://stackoverflow.com/questions/36560239/asp-net-core-createdatroute-failure for more on this
            return(service.Response(this, "GetSingleHybridTodo", new { id = result.Id }, item));
        }
 public async Task <ActionResult <WebApiMessageAndResult <TodoItemHybrid> > > GetSingleAsync(int id, [FromServices] ICrudServicesAsync service)
 {
     return(service.Response(await service.ReadSingleAsync <TodoItemHybrid>(id)));
 }
Beispiel #3
0
        public async Task <ActionResult <WebApiMessageAndResult <TodoItem> > > GetSingleAsync(int id, [FromServices] ICrudServicesAsync service)
        {
            var result = await service.ReadSingleAsync <TodoItem>(id);

            return(service.Response(result));
        }
Beispiel #4
0
        public async Task <ActionResult <WebApiMessageOnly> > DeleteReview(RemoveReviewDto item, [FromServices] ICrudServicesAsync service)
        {
            await service.UpdateAndSaveAsync(item, nameof(Book.RemoveReview));

            return(service.Response());
        }
Beispiel #5
0
        public async Task <ActionResult <WebApiMessageOnly> > Delete(int id, [FromServices] ICrudServicesAsync service)
        {
            await service.DeleteAndSaveAsync <TodoItemHybrid>(id);

            return(service.Response());
        }
Beispiel #6
0
        public async Task <ActionResult <CreateBookDto> > Post(CreateBookDto item, [FromServices] ICrudServicesAsync service)
        {
            var result = await service.CreateAndSaveAsync(item, nameof(Book.CreateBook));

            return(service.Response(this, "GetSingleBook", new { id = result.BookId }, item));
        }
Beispiel #7
0
 public async Task <ActionResult <WebApiMessageAndResult <List <Review> > > > GetReviewsManyAsync([FromServices] ICrudServicesAsync service)
 {
     return(service.Response(await service.ReadManyNoTracked <Review>().ToListAsync()));
 }