public CatalogViewModel GetCatalogModel()
        {
            var catalogFilter = new CatalogFilterViewModel
            {
                Filter = new FilterViewModel
                {
                    FilterByBrand = new FilterByBrandViewModel
                    {
                        Brands       = GetBrands(),
                        CurrentBrand = "All"
                    },
                    SortingBy = SortBy.None
                },
                Pagination = new PaginationViewModel
                {
                    CurrentPage  = 1,
                    ItemsPerPage = 4,
                    TotalItems   = _catalogService.GetAll().Count()
                }
            };
            var catalogItems = GetCatalogItems(catalogFilter);

            var viewmodel = new CatalogViewModel
            {
                CatalogItems = catalogItems,
                Filter       = catalogFilter
            };

            return(viewmodel);
        }
Beispiel #2
0
        /// <summary>
        /// Function: Lấy Danh sách Danh mục
        /// </summary>
        /// <history>
        /// [Lương Mỹ] ProductManagerViewModel [20/04/2019]
        /// </history>
        public List <SelectListItem> GetCatalogs(int mode)
        {
            ICatalogService catalogService = ServiceLocator.Current.GetInstance <ICatalogService>();

            //
            List <Catalog> dataCatalog = catalogService.GetAll(1);
            //
            List <SelectListItem> catalogs = new List <SelectListItem>();

            if (mode == 0)
            {
                catalogs.Add(new SelectListItem()
                {
                    Text = "Tất cả", Value = "0"
                });
            }
            foreach (var item in dataCatalog)
            {
                catalogs.Add(new SelectListItem()
                {
                    Text = item.Name, Value = item.Id.ToString()
                });
            }
            return(catalogs);
        }
Beispiel #3
0
        public async Task <IActionResult> Index(Guid categoryId)
        {
            var currentBasketId = Request.Cookies.GetCurrentBasketId(_settings);

            var getBasket = currentBasketId == Guid.Empty
                ? Task.FromResult <Basket>(null)
                : _shoppingBasketService.GetBasket(currentBasketId);

            var getCategories = _catalogService.GetCategories();

            var getEvents = categoryId == Guid.Empty
                ? _catalogService.GetAll()
                : _catalogService.GetByCategoryId(categoryId);

            await Task.WhenAll(getBasket, getCategories, getEvents);

            var numberOfItems = getBasket.Result?.NumberOfItems ?? 0;

            return(View(
                       new EventListModel
            {
                Events = getEvents.Result,
                Categories = getCategories.Result,
                NumberOfItems = numberOfItems,
                SelectedCategory = categoryId
            }
                       ));
        }
Beispiel #4
0
        public async Task <IActionResult> Items()
        {
            AddCookie();

            //var cookie = new CookieHeaderValue("id", "12345"); // имя куки - id, значение - 12345
            //cookie.Expires = DateTimeOffset.Now.AddDays(1); // время действия куки - 1 день
            //cookie.Domain = Request.RequestUri.Host; // домен куки
            //cookie.Path = "/"; // путь куки
            //var response = Request.CreateResponse<IEnumerable<Book>>(HttpStatusCode.OK, db.Books);
            //response.Headers.AddCookies(new CookieHeaderValue[] { cookie });
            //return response;


            //get cookie
            //string Id = "";

            //CookieHeaderValue cookie = Request.Headers.GetCookies("id").FirstOrDefault();
            //if (cookie != null)
            //{
            //    Id = cookie["id"].Value;
            //}

            var all = await _catalogService.GetAll();

            return(Ok(all));
        }
Beispiel #5
0
        public async Task <IActionResult> Get()
        {
            ICatalogService catalogService = ServiceProxy
                                             .Create <ICatalogService>(new Uri("fabric:/Store/Catalog.Service"),
                                                                       new ServicePartitionKey());

            var all = await catalogService.GetAll();

            return(Ok(all));
        }
Beispiel #6
0
        public async Task <ActionResult <ICollection <CatalogSummaryDto> > > GetAll([FromQuery] string fatherId)
        {
            var result = await _service.GetAll(fatherId);

            if (result == null)
            {
                return(NotFound());
            }

            return(Ok(result));
        }
 public IActionResult Get()
 {
     try
     {
         var allCat = _catalogService.GetAll().ToApiModels();
         return(Ok(allCat));
     }
     catch (Exception ex)
     {
         ModelState.AddModelError("GetCatalogs", ex.Message);
         return(BadRequest(ModelState));
     }
 }
        public OrderViewModel PrepareSessionCartOrder()
        {
            var cart = _cartService.Cart;

            var cartItemIds  = cart.Lines.Select(cl => cl.Id);
            var catalogItems = _catalogService.GetAll()
                               .Where(ci => cartItemIds.Any(id => id == ci.Id));

            var orderViewModel = new OrderViewModel();

            orderViewModel.CreationDate = DateTime.Now.ToUniversalTime();
            orderViewModel.ItemsPreview = new OrderItemsPreviewViewModel();
            // Order items from db
            foreach (var catalogItem in catalogItems)
            {
                var orderItem = new OrderItemViewModel
                {
                    CreationDate = DateTime.Now.ToUniversalTime(),
                    Name         = catalogItem.Name,
                    ItemId       = catalogItem.Id,
                    Quantity     = cart.Lines.Where(cl => cl.Id == catalogItem.Id).First().Quantity
                };

                if (catalogItem.DiscountId.HasValue)
                {
                    var discount = _discountService.GetById(catalogItem.DiscountId.Value);
                    orderItem.UnitPrice = discount.NewValue;
                }
                else
                {
                    orderItem.UnitPrice = catalogItem.Price;
                }

                orderViewModel.ItemsPreview.Items.Add(orderItem);
            }

            return(orderViewModel);
        }
        internal IEnumerable <TDto> RetrieveAllCatalog <TDto>(IDataConverter <CatalogData, TDto> converter)
            where TDto : class
        {
            ArgumentValidator.IsNotNull("converter", converter);
            ICatalogService service = UnitOfWork.GetService <ICatalogService>();

            var query = service.GetAll();

            if (query.HasResult)
            {
                return(query.DataToDtoList(converter));
            }

            return(null);
        }
        internal IList <BindingListItem> GetBindingList()
        {
            // Only get Catalogs which are not Global
            List <BindingListItem> dataSource = new List <BindingListItem>();
            ICatalogService        service    = UnitOfWork.GetService <ICatalogService>();
            var query = service.GetAll();

            if (query.HasResult)
            {
                foreach (CatalogData data in query.DataList.Where(o => o.IsGlobal != true))
                {
                    dataSource.Add(new BindingListItem(data.Id, data.Name));
                }
            }

            return(dataSource);
        }
        public async Task <IActionResult> GetAllCatalog([FromHeader(Name = "Authorization")] string authorization)
        {
            if (!_userValidationService.CheckAuthorizationToken(authorization))
            {
                return(Unauthorized());
            }
            if (!(await _userValidationService.Validate(authorization.Split(" ")[1])))
            {
                return(Unauthorized());
            }

            var userRef = await _userValidationService.GetUserRef(authorization.Split(" ")[1]);

            IEnumerable <CatalogDto> list = _catalogService.GetAll();

            _logger.logInformation(userRef, LoggingEvents.GetAllOk, "Getting All Catalogs: {0}", EnumerableUtils.convert(list));
            return(Ok(list));
        }
        // GET: Discount/CreateStep1
        public IActionResult CreateStep1()
        {
            var model = _catalogService.GetAll();

            return(View(model));
        }
Beispiel #13
0
 public async Task <IActionResult> Index()
 {
     return(View(await _catalogService.GetAll()));
 }
        public IActionResult Index()
        {
            var model = _catalogService.GetAll();

            return(View(model));
        }
        public async Task <IActionResult> Index()
        {
            var products = await _catalogService.GetAll();

            return(View(products));
        }
Beispiel #16
0
        public async Task <IActionResult> Get()
        {
            var items = await _catalogService.GetAll();

            return(Ok(items));
        }
Beispiel #17
0
 public IHttpActionResult GetAll()
 {
     return(Ok(_catalogService.GetAll()));
 }