示例#1
0
        // Populate the Initial Data in SQLLITE TABLES.
        public async Task SeedData()
        {
            await SeedBrands();                // Shoe BRANDS
            await SeedShoeCategories();        // Shoe Categories
            await SeedColors();                // Shoe COlors
            await SeePerson();                 // Men, Women, Kids
            await SeedSize();                  // Shoe Sizes.

            await _context.SaveChangesAsync(); // Svae changes to database

            // Update
            _brands = await _brandService.GetAll();

            _categories = await _categoryService.GetAll();

            _colors = await _colorService.GetAll();

            _sizes = await _sizeService.GetAll();

            _persons = await _personService.GetAll();

            await SeedProducts();  // Create Products

            await _context.SaveChangesAsync();

            _products = await _productService.GetAll();

            await SeedProductVariantColorAndSizes();  // Create Product Variants
        }
        public ActionResult <IEnumerable <SizeDto> > GetAll()
        {
            var colors = _sizeService.GetAll();

            if (colors == null)
            {
                return(NotFound("Empty list"));
            }
            return(Ok(colors));
        }
        public IActionResult Edit(int id)
        {
            List <SizeViewModel> sizes = _sizeService.GetAll();

            ViewBag.SizesForSelection = sizes.ToSelectListItems();

            List <PizzaViewModel> pizzas = _pizzaService.GetAll();

            ViewBag.PizzasForSelection = pizzas.ToSelectListItems();
            return(View(_pizzaSizeService.GetById(id)));
        }
示例#4
0
        public ActionResult Create()
        {
            ProductListViewModel model = new ProductListViewModel()
            {
                Categories = new SelectList(_categoryService.GetAll(), "CategoryID", "CategoryName").ToList(),
                Sizes      = new SelectList(_sizeService.GetAll(), "SizeID", "SizeValue").ToList(),
                Colors     = new SelectList(_colorService.GetAll(), "ColorID", "ColorValue").ToList(),
                Suppliers  = new SelectList(_supplierService.GetAll(), "SupplierID", "CompanyName").ToList(),
                Product    = new Product()
            };

            return(View(model));
        }
示例#5
0
        public HttpResponseMessage GetAll(HttpRequestMessage request)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;
                var model = _sizeService.GetAll();
                IEnumerable <SizeViewModel> modelVm = Mapper.Map <IEnumerable <Size>, IEnumerable <SizeViewModel> >(model);

                response = request.CreateResponse(HttpStatusCode.OK, modelVm);

                return response;
            }));
        }
示例#6
0
        public HttpResponseMessage GetAll(HttpRequestMessage request)
        {
            Func <HttpResponseMessage> func = () =>
            {
                var model = _SizeService.GetAll();
                //var a = _SizeService.GetSizeByNotPrice(22);
                var responseData = Mapper.Map <IEnumerable <Size>, IEnumerable <SizeViewModel> >(model);

                var response = request.CreateResponse(HttpStatusCode.OK, responseData);
                return(response);
            };

            return(CreateHttpResponse(request, func));
        }
示例#7
0
        public HttpResponseMessage GetAll(HttpRequestMessage request, int page, int pageSize, string filter = null)
        {
            return CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;
                int totalRow = 0;

                var model = _sizeService.GetAll();

                if (!string.IsNullOrEmpty(filter))
                {
                    model = model.Where(x => x.Name.ToLower().Contains(filter) || x.Name.ToUpper().Contains(filter));
                }

                totalRow = model.Count();

                var query = model.OrderBy(x => x.ID).Skip(page - 1 * pageSize).Take(pageSize).ToList();

                var responseData = Mapper.Map<List<Size>, List<SizeViewModel>>(query);

                PaginationSet<SizeViewModel> pagedSet = new PaginationSet<SizeViewModel>()
                {
                    PageIndex = page,
                    PageSize = pageSize,
                    TotalRows = totalRow,
                    Items = responseData,
                };

                response = request.CreateResponse(HttpStatusCode.OK, pagedSet);

                return response;
            });
        }
示例#8
0
        public async Task <IActionResult> GetAll()
        {
            //var dataReturn = await _productService.GetAll();
            var model = await _sizeService.GetAll();

            return(new OkObjectResult(model));
        }
示例#9
0
        public async Task <IActionResult> Details(int id)
        {
            ViewData["BodyClass"] = "product-page";
            var product             = _productService.GetById(id);
            var productbyCategories = _productService.GetProductsByCategoryId(product.CategoryId).Where(x => x.Status == Status.Active);

            var details = new DetailViewModel();

            details.ProductViewModel         = product;
            details.ProductCategoryViewModel = _productCategoryService.GetById(product.CategoryId);
            details.colorViewModels          = _colorService.GetAll();
            details.sizeViewModels           = _sizeService.GetAll();
            details.productImageViewModels   = _productService.GetProductImages(product.Id);
            details.RelatedProducts          = productbyCategories.Take(7).ToList();
            details.SaleProducts             = productbyCategories.Where(x => x.PromotionPrice != null).Take(7).ToList();
            details.TagViewModels            = _productService.GetTagsByProduct(product.Id);
            if (User.Identity.IsAuthenticated)
            {
                var user = await _userManager.FindByNameAsync(User.Identity.Name);

                if (user != null)
                {
                    details.IsInWishList = _productService.IsExistedInWishlist(id, user.Id);
                }
            }
            return(View(details));
        } // product detail
示例#10
0
        public IActionResult Details(int id)
        {
            ViewData["BodyClass"] = "product-page";
            var model = new DetailViewModel
            {
                Product         = _productService.GetById(id),
                RelatedProducts = _productService.GetRelatedProducts(id, 9),
                UpsellProducts  = _productService.GetUpsellProducts(6),
                ProductImages   = _productService.GetImages(id),
                Tags            = _productService.GetProductTags(id),
                ListColors      = _colorService.GetAll().Select(m => new SelectListItem()
                {
                    Value = m.Id.ToString(),
                    Text  = m.Name
                }).ToList(),
                ListSizes = _sizeService.GetAll().Select(m => new SelectListItem()
                {
                    Value = m.Id.ToString(),
                    Text  = m.Name
                }).ToList()
            };

            model.Category = _productCategoryService.GetById(model.Product.CategoryId);
            return(View(model));
        }
示例#11
0
        public ActionResult Index()
        {
            SizeListViewModel model = new SizeListViewModel()
            {
                Sizes = _sizeService.GetAll()
            };

            return(View(model));
        }
示例#12
0
        public IActionResult GetAll()
        {
            var model = _sizeService.GetAll();

            if (model != null)
            {
                return(new OkObjectResult(new { Status = true, Data = model }));
            }
            return(new OkObjectResult(new { Status = false }));
        }
示例#13
0
 public ActionResult Index()
 {
     try
     {
         return(View(Mapper.Map <IEnumerable <SizeViewModel> >(_sizeService.GetAll())));
     }
     catch (Exception ex)
     {
         return(JavaScript($"ShowResult('{ex.Message}','failure')"));
     }
 }
示例#14
0
 public IActionResult Get()
 {
     try
     {
         return(Ok(_sizeService.GetAll()));
     }
     catch (Exception ex)
     {
         return(BadRequest("Size not found"));
     }
 }
示例#15
0
        public IActionResult Get()
        {
            var list = sizeService.GetAll();

            if (list != null)
            {
                return(Ok(list));
            }
            else
            {
                return(NotFound("Empty"));
            }
        }
示例#16
0
 public async Task <IActionResult> SaveItemQuantity(ProductQuantityViewModel model)
 {
     if (ModelState.IsValid)
     {
         model.Size  = _sizeService.GetAll().FirstOrDefault(m => m.Id == model.SizeId);
         model.Color = _colorService.GetAll().FirstOrDefault(m => m.Id == model.ColorId);
         return(Json(new JsonResponse()
         {
             Success = true,
             Message = Constants.SaveDataSuccess,
             Data = await _viewRenderService.RenderToStringAsync("Product/_TableQuantity", model)
         }));
     }
     return(Json(new JsonResponse
     {
         Success = false,
         Message = Constants.SaveDataFailed,
         Errors = ModelState.Where(modelState => modelState.Value.Errors.Count > 0).ToDictionary(
             kvp => kvp.Key,
             kvp => kvp.Value.Errors.Select(e => e.ErrorMessage).FirstOrDefault()
             )
     }));
 }
示例#17
0
        public ActionResult Index()
        {
            var response = new HomeControllerIndexData
            {
                Pizzas = _pizzaSizeService.GetAll().Pizzas,
                Form   = new FormModel
                {
                    ExtraToppings = _toppingService.GetAll().Toppings.ToDictionary(x => x, y => false),
                    Sizes         = _sizeService.GetAll().Sizes.ToDictionary(x => x, y => false)
                }
            };

            if (Session["UserId"] == null)
            {
                Session["UserId"] = _userSessionService.NewUser();
            }
            else
            {
                response.Total    = _userSessionService.GetBasketTotalForUser(Session["UserId"].ToString());
                response.LoggedIn = _userSessionService.IsLoggedIn(Session["UserId"].ToString());
            }

            return(View(response));
        }
示例#18
0
        public async Task <ActionResult <IList <Size> > > GetAvailableShoesSizes()
        {
            var data = await _sizeService.GetAll();

            return(Ok(data.ToList()));
        }
示例#19
0
 public IActionResult Get()
 {
     return(new OkObjectResult(_sizeService.GetAll()));
 }
示例#20
0
 public IActionResult Index()
 {
     return(View(_sizeService.GetAll()));
 }
示例#21
0
        public IActionResult GetAll()
        {
            var data = _sizeService.GetAll();

            return(new OkObjectResult(data));
        }
示例#22
0
 public IActionResult Get()
 {
     return(Ok(_sizeService.GetAll()));
 }
示例#23
0
        public async Task <IActionResult> GetAll( )
        {
            var products = await _sizeService.GetAll();

            return(Ok(products));
        }
示例#24
0
        public async Task <IActionResult> ProductCatalog(int id, int?pageSize, string sortBy, int page = 1)
        {
            var productCategory = new ProductCategoryListViewModel();

            var categories = new List <LookupItem>();

            var category = await _productCategoryService.GetById(id);

            if (category.ParentId == null)
            {
                // lấy tất cả danh sách các sản phẩm cùng cha
                var dataReturn = await _productCategoryService.GetAllByParentId(category.Id);

                categories = dataReturn.AsParallel().WithExecutionMode(ParallelExecutionMode.ForceParallelism).Select(x => new LookupItem
                {
                    Id   = x.Id,
                    Name = x.Name,
                    Key  = x.SeoAlias
                }).ToList();
            }
            else
            {
                var dataReturn = await _productCategoryService.GetAllByParentId(category.ParentId.Value);

                categories = dataReturn.AsParallel().WithExecutionMode(ParallelExecutionMode.ForceParallelism).Select(x => new LookupItem
                {
                    Id   = x.Id,
                    Name = x.Name,
                    Key  = x.SeoAlias
                }).ToList();
            }

            var sizeVMs = await _sizeService.GetAll();

            productCategory.Sizes = sizeVMs.Select(x => new LookupItem
            {
                Id   = x.Id,
                Name = x.Name
            }).ToList();

            var colorVMs = await _colorService.GetAll();

            productCategory.Colors = colorVMs.Select(x => new LookupItem
            {
                Id   = x.Id,
                Name = x.Name
            }).ToList();

            var categoryCurrent = await _productCategoryService.GetById(id);


            productCategory.CurrentCategory = new LookupItem
            {
                Id   = categoryCurrent.Id,
                Name = categoryCurrent.SeoAlias
            };
            //get cart model

            productCategory.CartViewModels = HttpContext.Session.Get <List <ShoppingCartViewModel> >(CommonConstants.CartSession);

            productCategory.Categories = categories;
            return(View(productCategory));
        }
示例#25
0
 public ActionResult <List <SizeViewModel> > GetAll()
 {
     return(_pizzaSizeService.GetAll());
 }
示例#26
0
        public IActionResult GetSizes()
        {
            var sizes = _sizeService.GetAll();

            return(new OkObjectResult(sizes));
        }