public async Task <PagedList <Menu> > GetMenus(CategoryParams categoryParams, int HotelID) { var menus = _context.Menus.Include(c => c.Category).Where(u => u.HotelId == HotelID) .OrderBy(h => h.CategoryId).AsQueryable(); if (categoryParams.CategoryId > 0) { menus = menus.Where(u => u.CategoryId == categoryParams.CategoryId); } if (!string.IsNullOrEmpty(categoryParams.OrderBy)) { switch (categoryParams.OrderBy) { case "Name": menus = menus.OrderBy(u => u.MenuName); break; default: menus = menus.OrderBy(u => u.Category.CatName).ThenBy(u => u.MenuSortNumber); break; } } return(await PagedList <Menu> .CreateAsync(menus, categoryParams.PageNumber, categoryParams.PageSize)); }
public void AddCategory(CategoryParams @params) { var addProductCommand = new AddCategoryCommand( @params.Name); bus.SendCommand(addProductCommand); }
/// <summary> /// Create a new category Create a new custom transaction category for the authorized user, that can then be assigned to transactions via PATCH /transactions, and that will also be regarded in finAPI's automatic transactions categorization process. Must pass the user's access_token. /// </summary> /// <param name="body">Parameters of the new category</param> /// <returns>Category</returns> public Category CreateCategory(CategoryParams body) { var path = "/api/v1/categories"; path = path.Replace("{format}", "json"); var queryParams = new Dictionary <String, String>(); var headerParams = new Dictionary <String, String>(); var formParams = new Dictionary <String, String>(); var fileParams = new Dictionary <String, FileParameter>(); String postBody = null; postBody = ApiClient.Serialize(body); // http body (model) parameter // authentication setting, if any String[] authSettings = new String[] { "finapi_auth" }; // make the HTTP request IRestResponse response = (IRestResponse)ApiClient.CallApi(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings); if (((int)response.StatusCode) >= 400) { throw new ApiException((int)response.StatusCode, "Error calling CreateCategory: " + response.Content, response.Content); } else if (((int)response.StatusCode) == 0) { throw new ApiException((int)response.StatusCode, "Error calling CreateCategory: " + response.ErrorMessage, response.ErrorMessage); } return((Category)ApiClient.Deserialize(response.Content, typeof(Category), response.Headers)); }
public async Task <IActionResult> GetCategories(int projectId, [FromQuery] CategoryParams categoryParams) { var categoriesForRepo = await _repo.GetCategories(projectId, categoryParams); var categoryToReturn = _mapper.Map <IEnumerable <CategoryToReturnDto> >(categoriesForRepo); return(Ok(categoryToReturn)); }
public async Task <PagedList <Category> > GetCategories(int projectId, CategoryParams categoryParams) { var categroies = _context.Categories.AsQueryable(); categroies = categroies.Where(c => c.ProjectId == projectId); return(await PagedList <Category> .CreateAsync(categroies, categoryParams.PageNumber, categoryParams.PageSize)); }
public async Task <IActionResult> GetCategories(int hotelId, [FromQuery] CategoryParams categoryParams) { var categories = await _repo.GetCategories(categoryParams, hotelId); var categoriesToReturn = _mapper.Map <IEnumerable <CategoryForListDto> >(categories); Response.AddPagination(categories.CurrentPage, categories.PageSize, categories.TotalCount, categories.TotalPages); return(Ok(categoriesToReturn)); }
public async Task <IActionResult> GetCategoriesWithPaging([FromQuery] CategoryParams categoryParams) { var categoriesFromRepo = await _unitOfWork.Categories.GetCategoriesWithPaging(categoryParams); var categoriesToReturn = _mapper.Map <IEnumerable <CategoryForReturnDto> >(categoriesFromRepo); Response.AddPagination( categoriesFromRepo.CurrentPage, categoriesFromRepo.PageSize, categoriesFromRepo.TotalCount, categoriesFromRepo.TotalPages); return(Ok(categoriesToReturn)); }
public async Task <PagedList <Category> > GetCategoriesWithPaging(CategoryParams categoryParams) { var categories = oContext.Categories .OrderBy(p => p.CategoryName) .AsQueryable(); // Name if (!string.IsNullOrEmpty(categoryParams.CategoryName)) { categories = categories.Where(p => p.CategoryName.ToLower().Contains(categoryParams.CategoryName.ToLower())); } return(await PagedList <Category> .CreateAsync(categories, categoryParams.PageNumber, categoryParams.PageSize)); }
public async Task <PagedList <Category> > GetCategories(CategoryParams categoryParams, int HotelID) { var categories = _context.Categories.Where(u => u.HotelId == HotelID).OrderBy(u => u.HeaderName).AsQueryable(); if (!string.IsNullOrEmpty(categoryParams.OrderBy)) { switch (categoryParams.OrderBy) { case "HeaderName": categories = categories.OrderBy(u => u.HeaderName).ThenBy(u => u.CatName); break; default: categories = categories.OrderBy(u => u.CatName); break; } } return(await PagedList <Category> .CreateAsync(categories, categoryParams.PageNumber, categoryParams.PageSize)); }
public IActionResult Create([FromBody] CategoryParams @params) { categoriesService.AddCategory(@params); return(ActionResponse(@params)); }