// GET: Checkout
        public async Task <ActionResult> Index()
        {
            try
            {
                var cookie = Request.Cookies["UserId"].Value;
                if (cookie != null)
                {
                    var cart = _shoppingCartService.GetShoppingCartByUserId(cookie);
                    var user = await _userService.GetUserByIdAsync(cookie);

                    var products = ConvertDomainToModel.shoppingCartDetailModels(_shoppingCartDetailService.GetAllByCartId(cart.Id));

                    // check products in cart
                    if (cart.ShoppingCartDetails.Count() == 0)
                    {
                        return(RedirectToAction("Index", "Cart"));
                    }

                    var checkOutModel = new CheckoutViewModel()
                    {
                        shoppingCartDetailModels = products,
                        customerModel            = GetCustomerModel(user)
                    };
                    return(View(checkOutModel));
                }
                else
                {
                    return(RedirectToAction("Index", "Cart"));
                }
            }
            catch { return(RedirectToAction("Erorr", "Home")); }
        }
示例#2
0
        public ActionResult AddOrEditProductVariation(Guid?id)
        {
            try
            {
                var model = new ProVarationViewModel();

                model.DropDownProduct = DropDownListDomain.DropDownList_Product(_productService.SelectAll());
                model.DropDownVolume  = DropDownListDomain.DropDownList_Volume();

                if (id.HasValue)
                {
                    var productVariation = _productVariationService.GetById(id.Value);

                    model = ConvertDomainToModel.ConvertModelFromDomainToProVa(productVariation);

                    model.DropDownProduct = DropDownListDomain.DropDownList_Product(_productService.SelectAll());
                    model.DropDownVolume  = DropDownListDomain.DropDownList_Volume();

                    model.Image = _productImageService.GetProductImage(model.Id) == null ? null :
                                  ConvertDomainToModel.GetProductImage(_productImageService.GetProductImage(model.Id));

                    return(View(model));
                }
                else
                {
                    return(View(model));
                }
            }
            catch { return(RedirectToAction("Erorr500", "HomdeAdmin")); }
        }
 // GET: Cart
 public ActionResult Index()
 {
     try
     {
         var cart   = GetOrSetShoppingCart();
         var model  = GetShoppingCartModel(_shoppingCartService.GetShoppingCartByUserId(cart.UserId));
         var model2 = ConvertDomainToModel.shoppingCartDetailModels(model.ShoppingCartDetails);
         return(View(model2));
     }
     catch
     {
         return(RedirectToAction("Erorr", "Home"));
     }
 }
示例#4
0
 private IList <BrandViewModel> GetBrands(IList <Brand> brands)
 {
     return(brands.Select(x => new BrandViewModel
     {
         Id = x.Id,
         Name = x.Name,
         Summary = x.Summary,
         Logo = x.Logo,
         CreateDate = x.CreatedDate,
         UpdateDate = x.UpdatedDate,
         Products = ConvertDomainToModel.GetProduct_SummaryInfo(_productService.GetProductsByBrandId(x.Id)),
         IsActive = x.IsActive
     }).ToList());
 }
示例#5
0
 private IList <VendorViewModel> GetVendors(IList <Vendor> vendors)
 {
     return(vendors.Select(x => new VendorViewModel
     {
         Id = x.Id,
         Name = x.Name,
         Address = x.Address,
         PhoneNumber = x.PhoneNumber,
         CreateDate = x.CreatedDate,
         UpdateDate = x.UpdatedDate,
         Products = ConvertDomainToModel.GetProduct_SummaryInfo(_productService.GetProductsByVendorId(x.Id)),
         IsActive = x.IsActive
     }).ToList());
 }
示例#6
0
 /// <summary>
 /// get product variation have image with image id
 /// </summary>
 /// <param name="proVas">ProductVatiation List</param>
 /// <returns>ProVarationViewModel List</returns>
 public IList <ProVarationViewModel> GetProductVariations(IList <ProductVariation> proVas)
 {
     return(proVas.Select(x => new ProVarationViewModel
     {
         Id = x.Id,
         SKU = x.SKU,
         StockQuantity = x.StockQuantity,
         Price = x.Price,
         Volume = x.Volume,
         Image = _productImageService.GetProductImage(x.Id) == null ? null :
                 ConvertDomainToModel.GetProductImage(_productImageService.GetProductImage(x.Id)),
         DiscountPrice = x.DiscountPrice,
         CreateDate = x.CreatedDate,
         UpdateDate = x.UpdatedDate,
         IsActive = x.IsActive
     }).ToList());
 }
示例#7
0
        /// <summary>
        /// Detail Brand
        /// </summary>
        /// <param name="id"></param>
        /// <returns>Detail View</returns>
        public ActionResult DetailBrand(Guid id)
        {
            var brand = _brandService.GetById(id);
            var model = new BrandViewModel
            {
                Id         = brand.Id,
                Name       = brand.Name,
                Logo       = brand.Logo,
                CreateDate = brand.CreatedDate,
                IsActive   = brand.IsActive,
                Summary    = brand.Summary,
                Products   = ConvertDomainToModel.GetProduct_SummaryInfo(_productService.GetProductsByBrandId(brand.Id)),
                UpdateDate = brand.UpdatedDate,
            };

            return(View(model));
        }
示例#8
0
        /// <summary>
        /// Detail Brand
        /// </summary>
        /// <param name="id"></param>
        /// <returns>Detail View</returns>
        public ActionResult DetailVendor(Guid id)
        {
            var vendor = _vendorService.GetById(id);
            var model  = new VendorViewModel
            {
                Id          = vendor.Id,
                Name        = vendor.Name,
                Address     = vendor.Address,
                CreateDate  = vendor.CreatedDate,
                IsActive    = vendor.IsActive,
                Email       = vendor.Email,
                PhoneNumber = vendor.PhoneNumber,
                Products    = ConvertDomainToModel.GetProduct_SummaryInfo(_productService.GetProductsByVendorId(vendor.Id)),
                UpdateDate  = vendor.UpdatedDate,
            };

            return(View(model));
        }
示例#9
0
        public ActionResult Index()
        {
            try
            {
                var model = new HomeViewModel();

                model.BannerMain   = GetBanner(_bannerService.GetBannerByType(BannerType.MainBanner));
                model.BannerMen    = GetBanner(_bannerService.GetBannerByType(BannerType.MenBanner));
                model.BannerWomen  = GetBanner(_bannerService.GetBannerByType(BannerType.WomenBanner));
                model.SquareMen    = GetProAd(_productAdvertisement.GetProductAdvertisementByType(ProductAdvertisementType.MenSquareBanner));
                model.Squarewomen  = GetProAd(_productAdvertisement.GetProductAdvertisementByType(ProductAdvertisementType.WomenSquareBanner));
                model.SquareUnisex = GetProAd(_productAdvertisement.GetProductAdvertisementByType(ProductAdvertisementType.UnisexSquareBanner));

                model.BannerSlider = GetAllSliderBanner();
                var productsHot = _productService.GetProductsByCategotyName("Hot");
                model.productsHot = ConvertDomainToModel.GetProducts(productsHot);
                var productsNew = _productService.GetProductsByCategotyName("New Products");
                model.productcsNew = ConvertDomainToModel.GetProducts(productsNew);
                return(View(model));
            }
            catch { return(RedirectToAction("Erorr", "Home")); }
        }
示例#10
0
        /// <summary>
        /// function search
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public ActionResult SearchProduct(string SearchText, int?pageIndex)
        {
            try
            {
                if (!string.IsNullOrEmpty(SearchText))
                {
                    int pageSize = 20;
                    var page     = pageIndex ?? 1;

                    var result = ConvertDomainToModel.GetProducts(_productService.ManySearch(SearchText));

                    ViewBag.SearchText = SearchText;
                    return(View(result.ToPagedList(page, pageSize)));
                }
                else
                {
                    ViewBag.Error = "Not Empty";
                    return(RedirectToAction("index"));
                }
            }
            catch { return(RedirectToAction("Erorr", "Home")); }
        }
示例#11
0
        /// <summary>
        /// Product Detail
        /// </summary>
        /// <param name="id">Product ID</param>
        /// <returns>View with model info product</returns>
        public ActionResult ProductDetail(Guid id, string volume)
        {
            try
            {
                string vo;
                // get volume
                if (volume == null)
                {
                    vo = _productVariationService.GetVolumeFisrtById(id);
                }
                else
                {
                    vo = volume;
                }

                var model = GetProductVaDetailViewModel(_productVariationService.GetProductVariationByIdAndVolume_version2(id, vo));

                var product = _productService.GetProductById(id);
                ViewBag.ProductRelate = ConvertDomainToModel.GetProducts(_productService.GetProductsByBrandId(product.Brand_Id));
                return(View(model));
            }
            catch { return(RedirectToAction("Erorr", "Home")); }
        }