// 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))); }
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)); }
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; })); }
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)); }
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; }); }
public async Task <IActionResult> GetAll() { //var dataReturn = await _productService.GetAll(); var model = await _sizeService.GetAll(); return(new OkObjectResult(model)); }
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
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)); }
public ActionResult Index() { SizeListViewModel model = new SizeListViewModel() { Sizes = _sizeService.GetAll() }; return(View(model)); }
public IActionResult GetAll() { var model = _sizeService.GetAll(); if (model != null) { return(new OkObjectResult(new { Status = true, Data = model })); } return(new OkObjectResult(new { Status = false })); }
public ActionResult Index() { try { return(View(Mapper.Map <IEnumerable <SizeViewModel> >(_sizeService.GetAll()))); } catch (Exception ex) { return(JavaScript($"ShowResult('{ex.Message}','failure')")); } }
public IActionResult Get() { try { return(Ok(_sizeService.GetAll())); } catch (Exception ex) { return(BadRequest("Size not found")); } }
public IActionResult Get() { var list = sizeService.GetAll(); if (list != null) { return(Ok(list)); } else { return(NotFound("Empty")); } }
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() ) })); }
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)); }
public async Task <ActionResult <IList <Size> > > GetAvailableShoesSizes() { var data = await _sizeService.GetAll(); return(Ok(data.ToList())); }
public IActionResult Get() { return(new OkObjectResult(_sizeService.GetAll())); }
public IActionResult Index() { return(View(_sizeService.GetAll())); }
public IActionResult GetAll() { var data = _sizeService.GetAll(); return(new OkObjectResult(data)); }
public IActionResult Get() { return(Ok(_sizeService.GetAll())); }
public async Task <IActionResult> GetAll( ) { var products = await _sizeService.GetAll(); return(Ok(products)); }
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)); }
public ActionResult <List <SizeViewModel> > GetAll() { return(_pizzaSizeService.GetAll()); }
public IActionResult GetSizes() { var sizes = _sizeService.GetAll(); return(new OkObjectResult(sizes)); }