public async Task <IEnumerable <Category> > Handle(GetCategories request, CancellationToken cancellationToken) { var categories = await _context.Categories .ToListAsync(cancellationToken); return(categories); }
public async Task <List <CategoryViewModel> > Handle(GetCategories message, CancellationToken cancellationToken) { if (message.ParentId != null && message.ParentId <= 0) { throw new Exception(Constants.INVALID_ID); } var command = context.Categories .Where(c => c.ForEntity == "bun"); if (message.ParentsOnly == true) { command = command.Where(c => c.ParentId == null); } else { command = command.Where(c => c.ParentId == message.ParentId); } var models = await command .Select(c => mapper.Map <CategoryViewModel>(c)) .ToListAsync(cancellationToken); return(models); }
public async Task <QueryResult <CategoryResponse> > Handle(GetCategories request, CancellationToken cancellationToken) { Expression <Func <Category, bool> > deletedFilter = x => !x.IsDeleting; Expression <Func <Category, bool> > searchFilter = x => (string.IsNullOrWhiteSpace(request.SearchQuery)) || x.Name.ToUpper().Contains(request.SearchQuery.ToUpper()); var count = await _shopContext.Categories .Where(deletedFilter) .Where(searchFilter) .CountAsync(cancellationToken).ConfigureAwait(false); if (count == 0) { return(new QueryResult <CategoryResponse>()); } var categories = await _shopContext.Categories .Where(deletedFilter) .Where(searchFilter) .AddPaging(request) .ToListAsync(cancellationToken).ConfigureAwait(false); var response = categories.Select(x => x.ToResponse()).ToList(); var paging = CreatePaging(request, count); return(new QueryResult <CategoryResponse>(response, paging)); }
public ReactiveAddIncomeTransactionViewModel(ITransactionService transactionService, IViewModelNavigationService navigationService, ICategoriesService categoriesService, IUserDialogs userDialogs) { _transactionService = transactionService; _navigationService = navigationService; _categoriesService = categoriesService; var isValidCategory = this.WhenAnyValue(m => m.SelectedCategory) .Select(c => c != null); var isValidValue = this.WhenAnyValue(m => m.Value) .Select(IsValidValue); var canAddTransaction = isValidCategory.Merge(isValidValue); AddTransactionCommand = ReactiveCommand.CreateFromObservable <Unit>(AddTransactionAsync, canAddTransaction); GetCategories = ReactiveCommand.CreateFromObservable <Unit, IEnumerable <CategoryModel> >(GetCategoriesAsync); _categories = GetCategories .Select(categories => new ObservableCollection <CategoryModel>(categories)) .Select(categories => new ReadOnlyObservableCollection <CategoryModel>(categories)) .ToProperty(this, vm => vm.Categories); AddTransactionCommand.ThrownExceptions.Subscribe(ex => userDialogs.Alert(ex.Message)); AddTransactionCommand .Subscribe(Observer.Create <Unit>(OnAddTransactionComplete)); StateObservable .Where(s => s == ViewModelState.Disappered) .Subscribe(Observer.Create <ViewModelState>(ClearData)); StateObservable.Where(s => s == ViewModelState.Appeared) .Select(_ => Unit.Default) .InvokeCommand(GetCategories); }
public IActionResult Index() { var g = new GetCategories(_configuration); var CategoryList = g.GetList(); return(View("../Task/Supplier/AddTask", CategoryList)); }
public IActionResult LoadUnRelatedCategory(long?ID, long?CategoryID, long?ProductID, long?ProductDetailID, long?CategoryLevel, long?LineOfBusniess, long?SubLineOfBusniess, long?langId) { GetProductCategory operation = new GetProductCategory(); GetCategories operation2 = new GetCategories(); operation.ID = ID; operation.ProductID = ProductID; operation.CategoryID = CategoryID; operation.ProductDetailID = ProductDetailID; operation.CategoryLevel = CategoryLevel; operation.LineOfBusniess = LineOfBusniess; operation.SubLineOfBusniess = SubLineOfBusniess; operation2.LineOfBusniess = LineOfBusniess; operation2.SubLineOfBusniess = SubLineOfBusniess; operation2.CategoryLevel = CategoryLevel; if (langId.HasValue) { operation.LangID = langId; operation2.LangID = langId; } else { operation.LangID = 1; operation2.LangID = 1; } var result = operation.QueryAsync().Result; var productCategories = (List <ProductCategory>)result; var categories = (List <Category>)operation2.QueryAsync().Result; List <ProductCategory> RelatedCategories = new List <ProductCategory>(); List <Category> UnRelatedCategories = new List <Category>(); if (productCategories.Count > 0) { RelatedCategories = productCategories.Where(p => categories.Any(s => s.ID == p.CategoryID && (s.SubLineOfBusniess == SubLineOfBusniess || s.SubLineOfBusniess == null))).ToList(); UnRelatedCategories = categories.Where(s => productCategories.Any(p => p.CategoryID != s.ID && (s.SubLineOfBusniess == SubLineOfBusniess || s.SubLineOfBusniess == null))).ToList(); UnRelatedCategories = UnRelatedCategories.Where(un => !RelatedCategories.Exists(re => un.ID == re.CategoryID)).ToList(); } else { UnRelatedCategories = categories.Where(s => s.SubLineOfBusniess == SubLineOfBusniess || s.SubLineOfBusniess == null).ToList(); } if (result is ValidationsOutput) { return(Ok(new ApiResult <List <ValidationItem> >() { Data = ((ValidationsOutput)result).Errors })); } else { return(Ok(new { UnRelatedCategories, RelatedCategories })); } }
protected override IEnumerable <CategoryViewModel> HandleCore(GetCategories query) { return(_dbContext.Categories .Where(x => x.Parent == null && x.Visible) .OrderBy(x => x.Ordinal) .Select(Transform)); }
public IActionResult Load(long?ID, long?langId, long?lineOfBussniess, long?subLineOfBussniess, long?categoryLevel) { GetCategories operation = new GetCategories(); operation.ID = ID; operation.CategoryLevel = categoryLevel; operation.LineOfBusniess = lineOfBussniess; operation.SubLineOfBusniess = subLineOfBussniess; if (langId.HasValue) { operation.LangID = langId; } else { operation.LangID = 1; } var result = operation.QueryAsync().Result; if (result is ValidationsOutput) { return(Ok(new ApiResult <List <ValidationItem> >() { Data = ((ValidationsOutput)result).Errors })); } else { return(Ok((List <Category>)result)); } }
public IActionResult EditTask(int Id) { GetOpenTasks q = new GetOpenTasks(_configuration); GetCategories g = new GetCategories(_configuration); var CategoryList = g.GetList(); ViewBag.Task = q.GetSingleTask(Id); return(View("../Task/Supplier/EditTask", CategoryList)); }
public object GetJson(GetCategories request) { using (var db = dbFactory.Open()) { var categories = db.Select <Category>(); return(new CategoriesResponse { Status = "success", Data = categories }); } }
public GetCategoriesResponse GetCategories() { using (JsConfig .With(propertyConvention: PropertyConvention.Lenient, emitLowercaseUnderscoreNames: true, emitCamelCaseNames: false)) { var request = new GetCategories(); return(client.Get(request)); } }
public object Get(GetCategories request) { using (IDbConnection db = DbFactory.Open()) { var categories = db.Select<Category>().ToList(); return new GetCategoriesResponse { Result = categories.ToList() }; } }
public async Task GetSubCategories_Expected2Categories() { var queryHandler = new GetCategoriesHandler(BasicNeeds); var query = new GetCategories() { ParentsOnly = false, ParentId = 1 }; var actual = await queryHandler.Handle(query, CancellationToken.None); Assert.IsTrue(actual.Count == 2); }
public object Get(GetCategories request) { var result = icategoryService.GetAllCategories(); if (result.Success) { return(result.Entities.ToList()); } // STATUS CODE return(null); }
public async Task ListCategories() { APIResponse response = await GetCategories.ExecuteStrategy(null); if (response.IsSuccess) { Categories = JsonConvert.DeserializeObject <List <CategoryModel> >(response.Response); } else { Exception e; } }
public void OnGet( [FromServices] GetProducts getProducts, [FromServices] GetCategories getCategories, int pageNumber = 1, int pageSize = PageZize) { IndexViewModel = new IndexViewModel { Products = getProducts.Do(pageNumber, pageSize), Categories = getCategories.Do() }; var taskCount = getProducts.GetProductsCount(); int count = taskCount.Result; PageViewModel = new PageViewModel(count, pageNumber, PageZize); }
public static void Initial(DBContent content) { if (!content.Category.Any()) { content.Category.AddRange(GetCategories.Select(cont => cont.Value)); } if (!content.Goods.Any()) { content.AddRange( new Goods { name = "Иу Шань Шу Пуэр", shortDesc = @"""Знаменитый Юньнаньский чай""", longDesc = "Классика от Мэнхайской чайной фабрики - знаменитый V93", img = "/img/v93.jpg", price = 5m, isFavorite = true, isAvailable = true, Category = GetCategories["Пуэры"], }, new Goods { name = "Да Хун Пао", shortDesc = @"""Большой Красный Халат""", longDesc = "Наряду с теплыми медово-шоколадными нотами мирно соседствуют веселые звенящие цветочные ноты, дополняясь древесностью и фруктовостью", img = "/img/dhp.jpg", price = 5.5m, isFavorite = true, isAvailable = true, Category = GetCategories["Улуны"], }, new Goods { name = "Хун Маофен", shortDesc = @"""Красные Ворсистые Пики""", longDesc = "Бюджетнейший красный чай, выпивается мной литрами, когда нет желания церемониться", img = "/img/hmf.jpg", price = 3.2m, isFavorite = true, isAvailable = true, Category = GetCategories["Красный чай"], } ); } content.SaveChanges(); }
public void OnGetByCategoryId( [FromServices] GetProducts getProducts, [FromServices] GetCategories getCategories, string categoryId, int pageNumber = 1, int pageSize = PageZize) { IndexViewModel = new IndexViewModel { Products = getProducts.Do(categoryId, pageNumber, pageSize), Categories = getCategories.Do() }; selectedCategoryId = categoryId; var taskCount = getProducts.GetProductsCount(selectedCategoryId); int count = taskCount.Result; PageViewModel = new PageViewModel(count, pageNumber, PageZize); }
public void OnGetSearchProduct( [FromServices] GetProducts getProducts, [FromServices] GetCategories getCategories, string searchString) { IndexViewModel = new IndexViewModel { Products = string.IsNullOrEmpty(searchString) ? getProducts.Do(1, PageZize) : getProducts.Do(searchString), Categories = getCategories.Do() }; var taskCount = getProducts.GetProductsCount(); int count = taskCount.Result; PageViewModel = new PageViewModel(count, 1, PageZize); }
public string GetCategoriesList() { if (SecureAuthentication != null) { int Output = CheckLoginReturnUserId(SecureAuthentication).ValueFromSQL; if (Output > 0) { GetCategories proc = new GetCategories(); return("{\"CategoriesList\" : " + Serialize(proc.GetCategoriesList()) + "}"); } else { return(Serialize(new AuthResponse(0, Output == -1 ? "Authentication is NULL" : "Invalid Authentication"))); } } return(Serialize(new AuthResponse(0, "Authentication information not provided."))); }
public async Task ListCategories() { APIResponse response = await GetCategories.ExecuteStrategy(null); if (response.IsSuccess) { Categories = JsonConvert.DeserializeObject <List <CategoryModel> >(response.Response); /*int categoryIdxCounter = 0; * foreach (var c in Categories) * { * if (Product.IdCategory == c.IdCategory) * { * ProductIndexCategory = categoryIdxCounter; * } * categoryIdxCounter += 1; * }*/ } else { Exception e; } }
public IViewComponentResult Invoke() { List <MainCategory> mainMenu = new List <MainCategory>(); // netcore caching // https://docs.microsoft.com/en-us/aspnet/core/performance/caching/memory?view=aspnetcore-2.2 if (!_cache.TryGetValue(_menuCacheKey, out mainMenu)) { // "MainMenu" key not in cache, get data from DB mainMenu = new GetCategories(_ctx).DoMenu().ToList(); var cacheOptions = new MemoryCacheEntryOptions() // Sets cache entry size (only used if mimimum cache size is set in startup) //.SetSize(1) // Set's cache timeout period, resets if accessed .SetSlidingExpiration(TimeSpan.FromMinutes(30)); // Save menu data in cache _cache.Set(_menuCacheKey, mainMenu, cacheOptions); } return(View(mainMenu)); }
public async Task <IActionResult> Get([FromRoute] GetCategories query) => Select(await Dispatcher.QueryAsync(query));
public async Task <IEnumerable <CategoryDto> > HandleAsync(GetCategories query) { return(await _categoryService.BrowseAsync()); }
public IActionResult GetCategories( [FromServices] GetCategories getCategories) => Ok(getCategories.Do());
public async Task <IEnumerable <CategoryOfProduct> > HandleAsync(GetCategories query) { var categories = await _context.CategoriesOfProduct.OrderBy(cop => cop.Name).ToListAsync(); return(categories); }
public async Task <IActionResult> GetCategories([FromQuery] GetCategories query) { var result = await _mediator.Send(query); return(JsonResult(result)); }
public Task <List <CategoryReadModel> > HandleAsync(GetCategories query) { return(_categoryRead.GetCategoriesAsync()); }
public void OnGet([FromServices] GetFeaturedProducts getFeaturedProducts, [FromServices] GetCategories getCategories) { Products = getFeaturedProducts.Action(); Categories = getCategories.Action(); }
public IActionResult GetCategories([FromServices] GetCategories getCategories) { var categories = getCategories.Do(); return(Ok(categories)); }
public async Task <PageModel <CategoryModel> > GetCategoriesAsync([FromBody] GetCategories getCategories) { return(await _mediator.Send(getCategories)); }