public ResponseModel_GetCatogries GetCatogries(GetCategoriesRequestModel model) { var response = new ResponseModel_GetCatogries { Success = false, Messages = new List <string>() }; if (model == null) { response.Messages.Add("model is not mapped"); response.Data = model; } else { try { var menuItems = ListService.GetCategories(model.Status); response.Data = menuItems; response.MessageContents = "Enjoy free delivery for the whole week from 10am-7pm"; response.ShowMessage = true; response.MessageTitle = "Free Delivery"; response.Messages.Add("Success"); response.Success = true; } catch (Exception excep) { response.Messages.Add("Something bad happened."); } } return(response); }
public async Task <IActionResult> GetCategories([FromQuery] GetCategoriesRequestModel options) { var cat = await categoryService.GetCategories(options); if (cat.Status == 1) { return(Ok(cat)); } else { return(NotFound(cat)); } }
public async Task <ApiResponse> GetCategories(GetCategoriesRequestModel options) { ApiResponse response = new ApiResponse(); int _pageNo = (options.pageNo == 0) ? 1: options.pageNo; int _pageLimit = (options.pageSize == 0) ? int.MaxValue : options.pageSize; var categories = _context.Categories.AsQueryable(); if (!String.IsNullOrEmpty(options.name)) { categories = categories.Where(x => x.Name.Contains(options.name)); } response.Data = await categories.Skip((_pageNo - 1) *_pageLimit).Take(_pageLimit).ToListAsync(); response.Status = 1; response.Message = "Category get successfully"; return(response); }
public IEnumerable <Category> GetCategoriesDefault(GetCategoriesRequestModel model = null) { if (model == null) { model = new GetCategoriesRequestModel(); } var id = this.GetUser(db).ID; var set = db.Categories.Where(c => c.User_ID == id || c.User_ID == null); if (model.Products.HasValue && model.Products.Value) { set.Include(c => c.Products); } if (model.UserInfo.HasValue && model.UserInfo.Value) { set.Include(c => c.UserInfo); } return(set.ToList()); }