public async Task <OperationResult <IEnumerable <Category> > > GetAllCategoryAsync(CancellationToken cancellation) { try { var categories = await CategoryEntite.AsNoTracking().ToListAsync(); return(OperationResult <IEnumerable <Category> > .BuildSuccessResult(categories)); } catch (Exception ex) { return(OperationResult <IEnumerable <Category> > .BuildFailure(ex.Message)); } }
public async Task <OperationResult <Category> > GetCategoryByIdAsync(Guid id, CancellationToken cancellation) { try { var category = await CategoryEntite.AsNoTracking().FirstOrDefaultAsync(x => x.Id == id); return(OperationResult <Category> .BuildSuccessResult(category)); } catch (Exception ex) { return(OperationResult <Category> .BuildFailure(ex.Message)); } }
public async Task <OperationResult <GetAllPaging <Category> > > GetAllCategoryPagingAsync(GetAllFormQuery formQuery, CancellationToken cancellation) { try { var role = CategoryEntite.AsNoTracking(); var sieveModel = new SieveModel { PageSize = formQuery.PageSize, Filters = formQuery.Filters, Page = formQuery.Page, Sorts = formQuery.Sorts }; var result = sieveProcessor.Apply(sieveModel, role); return(OperationResult <GetAllPaging <Category> > .BuildSuccessResult(new GetAllPaging <Category> { Records = result.AsEnumerable(), TotalCount = await CategoryEntite.CountAsync() })); } catch (Exception ex) { return(OperationResult <GetAllPaging <Category> > .BuildFailure(ex)); } }