public ActionResult DatHang() { CmnEntityModel currentUser = Session["CmnEntityModel"] as CmnEntityModel; OrderModel model = new OrderModel(); ManageDistrictDa dataAccess = new ManageDistrictDa(); if (currentUser == null) { return(RedirectToAction("Login", "Login")); } else { int HaNoiCity = 1; model.DISTRICT_LIST = dataAccess.getDistrictList(HaNoiCity).ToList().Select( f => new SelectListItem { Value = f.ID.ToString(), Text = f.Name }).ToList(); model.DISTRICT_LIST.Insert(0, new SelectListItem { Value = Constant.DEFAULT_VALUE, Text = "Chọn Quận/huyện" }); model.UserID = currentUser.ID; model.UserName = currentUser.UserName; model.Receive_District = currentUser.USER_DISTRICT; model.Receive_Address = currentUser.USER_ADDRESS; model.Email = currentUser.Email; model.Receive_Phone = currentUser.Phone; List <ItemGioHang> lstGioHang = LayGioHang(); ViewBag.lstGioHangItem = lstGioHang; model.TongSoLuong = TinhTongSoLuong(); model.TongTienHang = TongTien(); if (model.Receive_District > 0) { var getDistrict = dataAccess.getCityByID(model.Receive_District); model.PriceShip = getDistrict != null ? (int)getDistrict.PriceShip.Value : 0; } ManagePromotionDa promotionDa = new ManagePromotionDa(); var getPromotion = promotionDa.getPromotionForDiscount(model.TongTienHang); if (getPromotion != null) { var discount = getPromotion.Discount.HasValue ? getPromotion.Discount.Value : 0; model.PriceDiscountTotal = (int)(model.TongTienHang * discount / 100); } model.PriceTotal = model.TongTienHang + model.PriceShip - model.PriceDiscountTotal; } return(View(model)); }
public ActionResult getDictrictByID(long districtID) { if (Request.IsAjaxRequest()) { // Declare new DataAccess object ManageDistrictDa dataAccess = new ManageDistrictDa(); var exist = dataAccess.getCityByID(districtID); JsonResult result = Json(new { exist }, JsonRequestBehavior.AllowGet); return(result); } return(new EmptyResult()); }
// GET: ManageDistrict #region REGISTER/ UPDATE public ActionResult DistrictEdit(int CityCd = 0, int DistrictCd = 0) { CmnEntityModel currentUser = Session["CmnEntityModel"] as CmnEntityModel; if (currentUser == null || currentUser.IsAdmin == false) { return(RedirectToAction("Login", "Login")); } CityModel model = new CityModel(); CommonService comService = new CommonService(); ManageDistrictDa dataAccess = new ManageDistrictDa(); if (DistrictCd > 0) { var info = dataAccess.getCityByID(DistrictCd); if (info != null) { model.ID = info.ID; model.CITY_ID = info.Parent_Code.HasValue ? info.Parent_Code.Value : 0; model.Level = info.Level; model.Name = info.Name; model.PriceShip = info.PriceShip; model.Status = info.Status; model.CreatedDate = info.CreatedDate; model.ModifiedDate = info.ModifiedDate; } } model.CITY_LIST = dataAccess.getCityList(Constant.CityLevel.City).ToList().Select( f => new SelectListItem { Value = f.ID.ToString(), Text = f.Name }).ToList(); model.CITY_LIST.Insert(0, new SelectListItem { Value = Constant.DEFAULT_VALUE, Text = "" }); return(View(model)); }