public ActionResult Payment(long?sp) { ViewBag.TotalMoney = 0; ViewBag.TotalGram = 0; LoadDropdown loadDropdown = new LoadDropdown(); ViewBag.Location = loadDropdown.SearchLocationParenId(1, null); if (Session != null) { var entity = NlCheckout.GetSessionCard(Session); List <ShopCartItem> shopCartItems = new List <ShopCartItem>(); List <long> listIdShop = new List <long>(); if (sp == null) { foreach (var item in entity) { if (!listIdShop.Exists(x => x.Equals(item.Product.MemberId))) { listIdShop.Add(item.Product.MemberId); var shop = shopsBusiness.GetById(item.Product.MemberId); ShopCartItem shopCartItem = new ShopCartItem(); shopCartItem.ShopCart = shop; var listCart = entity.Where(x => x.Product.MemberId == item.Product.MemberId).ToList(); shopCartItem.ListCartItems = listCart; shopCartItems.Add(shopCartItem); } } } else { foreach (var item in entity) { if (!listIdShop.Exists(x => x.Equals(sp))) { listIdShop.Add(item.Product.MemberId); var shop = shopsBusiness.GetById((long)sp); ShopCartItem shopCartItem = new ShopCartItem(); shopCartItem.ShopCart = shop; var listCart = entity.Where(x => x.Product.MemberId == sp).ToList(); shopCartItem.ListCartItems = listCart; shopCartItems.Add(shopCartItem); } } var shopCartItemsentity = shopCartItems.FirstOrDefault(); ViewBag.TotalMoney = shopCartItemsentity.ListCartItems.Sum(x => x.Product.Price); var totalWeghit = 0.0; foreach (var listCartItem in shopCartItemsentity.ListCartItems) { totalWeghit += listCartItem.Quantity * listCartItem.Product.Weight; } ViewBag.TotalGram = totalWeghit; } return(View(shopCartItems)); } return(RedirectToRoute(new { controller = "Home", action = "Index" })); }
public JsonResult UpdateShop(Common.Shop obj) { try { ShopsBusiness _shopsBusiness = new ShopsBusiness(); var objentity = _shopsBusiness.GetById(obj.Id); objentity.Id = obj.Id; objentity.ShopName = obj.ShopName; objentity.Icon = obj.Icon; objentity.Address = obj.Address; objentity.LocationId = obj.LocationId; objentity.Phone = obj.Phone; objentity.Rate = obj.Rate; objentity.TotalView = obj.TotalView; objentity.Type = obj.Type; objentity.Status = obj.Status; objentity.BeginDate = obj.BeginDate; objentity.EndDate = obj.EndDate; objentity.ActiveDate = obj.ActiveDate; objentity.CreateDate = obj.CreateDate; objentity.ModifyDate = DateTime.Now; _shopsBusiness.Edit(objentity); return(Json(1));//Cập nhật thành công } catch (Exception) { throw; } }
public ActionResult EditAllInforAboutShop(Shop objShop, long receiverPhuong, HttpPostedFileBase iconShop) { ShopsBusiness shopBusiness = new ShopsBusiness(); ShopSettingsBusiness shopSettingBusiness = new ShopSettingsBusiness(); LoadDropdown loadDropdown = new LoadDropdown(); ViewBag.Location = loadDropdown.SearchLocationParenId(1, objShop.LocationId); LoadCombo loadDropStatus = new LoadCombo(); ViewBag.StatusShop = loadDropStatus.LoadStatus(); if (ModelState.IsValid && objShop != null) { var objShopDB = shopBusiness.GetById(objShop.Id); objShopDB.ShopName = objShop.ShopName; objShopDB.Address = objShop.Address; objShopDB.Phone = objShop.Phone; ////temp, sửa lại là dropdown //objShopDB.Type = objShop.Type; //objShopDB.Status = objShop.Status; objShopDB.LocationId = receiverPhuong; //objShopDB.ActiveDate = DateTime.ParseExact(datepicker1, "dd/MM/yyyy", null); if (iconShop != null && iconShop.ContentLength > 0) { string randomImage = Guid.NewGuid().ToString(); string pathImage = HttpContext.Server.MapPath("~/FileUpload"); string strurlimage = Function.ResizeImageNew(iconShop, 300, 300, pathImage, randomImage); Function.ResizeImageNew(iconShop, 500, 500, pathImage, randomImage); Function.ResizeImageNew(iconShop, 1000, 1000, pathImage, randomImage); objShopDB.Icon = strurlimage; } shopBusiness.Edit(objShopDB); return(View(objShopDB)); ////cập nhật shopSetting //var objShopSettingDB = shopSettingBusiness.GetDynamicQuery().Where(x => x.ShopId == objShop.Id).FirstOrDefault(); //if(objShopSettingDB != null) //{ // objShopSettingDB.Key = keyShopSetting; // objShopSettingDB.Value = valueShopSetting; // shopSettingBusiness.Edit(objShopSettingDB); //} //else //{ // ShopSetting objShopSetting = new ShopSetting(); // objShopSetting.ShopId = objShop.Id; // objShopSetting.Key = keyShopSetting; // objShopSetting.Value = valueShopSetting; // shopSettingBusiness.AddNew(objShopSetting); //} } else { return(View()); } }
public ActionResult EditAllInforAboutShop(long id) { var objShop = _shopsBusiness.GetById(id); if (objShop != null) { LoadDropdown loadDropdown = new LoadDropdown(); ViewBag.Location = loadDropdown.SearchLocationParenId(1, objShop.LocationId); LoadCombo loadDropStatus = new LoadCombo(); ViewBag.StatusShop = loadDropStatus.LoadStatus(); return(View(objShop)); } return(RedirectToAction("Index")); }
public JsonResult GetInforShop(long id) { try { var obj = _shopsBussiness.GetById(id); if (obj != null) { Common.Shop objentity = new Common.Shop(); objentity.Id = obj.Id; objentity.ShopName = obj.ShopName; objentity.Icon = obj.Icon; objentity.Address = obj.Address; objentity.LocationId = obj.LocationId; objentity.Phone = obj.Phone; objentity.Rate = obj.Rate; objentity.TotalView = obj.TotalView; objentity.Type = obj.Type; objentity.Status = obj.Status; objentity.BeginDate = obj.BeginDate; objentity.EndDate = obj.EndDate; objentity.ActiveDate = obj.ActiveDate; objentity.CreateDate = obj.CreateDate; objentity.ModifyDate = obj.ModifyDate; // // Common.ShopSupport shopSupport = new Common.ShopSupport(); objentity.Email = obj.ShopSupport.Email; objentity.Skype = obj.ShopSupport.Skype; objentity.Facebook = obj.ShopSupport.Facebook; //get số sản phẩm và số đơn hàng của shop var numProductOfShopDb = _productsBusiness.GetDynamicQuery().Count(x => x.MemberId == id); if (numProductOfShopDb != 0) { objentity.NumberOfProduct = numProductOfShopDb; } else { objentity.NumberOfProduct = 0; } var numOrderOfShopDb = _ordersBusiness.GetDynamicQuery().Count(x => x.IdShop == id); if (numOrderOfShopDb != 0) { objentity.NumberOfOrder = numOrderOfShopDb; } else { objentity.NumberOfOrder = 0; } return(Json(objentity, JsonRequestBehavior.AllowGet)); } else { return(Json(0)); } } catch (Exception) { //Write log throw; } }