// GET: PurchaseCar public ActionResult Index() { if (Session["has_login"] == null) { if (Session["ReturnToPurchaseCar"] == null) { Session["ReturnToPurchaseCar"] = "true"; } else { Session["ReturnToPurchaseCar"] = null; } return(Redirect("/Login")); } else { Session.Remove("ReturnToPurchaseCar"); ShopBusinessLogic.MemberPurchase memberPurchase = new ShopBusinessLogic.MemberPurchase(); var pcar_list = memberPurchase.getPurchaseCarList(Session["mem_phone"].ToString()).Select(pcar_info => new MemberPurchaseCarViewModel() { goods_id = pcar_info.goods_id, goods_num = pcar_info.goods_num, goods_name = memberPurchase.getGoods(pcar_info.goods_id).goods_name, goods_img_path = memberPurchase.getGoods(pcar_info.goods_id).goods_img_path, unit_price = memberPurchase.getGoods(pcar_info.goods_id).goods_price, total_price = memberPurchase.getGoods(pcar_info.goods_id).goods_price *pcar_info.goods_num, }).ToList(); var resView = new MemberPurchaseCarViewModel() { mem_phone = Session["mem_phone"].ToString(), pcar_list = pcar_list, }; return(View(resView)); } }
public ActionResult Index(MemberPurchaseCarViewModel memberPurchaseCarViewModels, string[] selected) { if (memberPurchaseCarViewModels == null) { return(Redirect("/Error")); } ShopBusinessLogic.MemberPurchase memberPurchase = new ShopBusinessLogic.MemberPurchase(); ShopBusinessLogic.LoginMember loginMember = new ShopBusinessLogic.LoginMember(); var submit_list = memberPurchaseCarViewModels.select_list; var select_list = new List <AccountModels>(); var address_list = loginMember.ShowMemberAddress(Session["mem_phone"].ToString()).Select(address_info => new MemberAddress() { address = address_info.address, address_tag = address_info.address_tag, }).ToList(); decimal all_price = 0; for (int i = 0; i < submit_list.Count; ++i) { if (selected[i] != null && selected[i] == "on") { var now_item = memberPurchase.getGoods(submit_list[i].goods_id); var item = new AccountModels() { goods_id = submit_list[i].goods_id, goods_name = now_item.goods_name, goods_num = submit_list[i].goods_num, unit_price = now_item.goods_price, total_price = now_item.goods_price * submit_list[i].goods_num, seller_phone = now_item.seller_phone, }; if (item.goods_num > 0) { all_price += item.total_price; select_list.Add(item); } } } var resView = new AccountModels() { mem_phone = Session["mem_phone"].ToString(), addresses = address_list, accountModeList = select_list, all_price = all_price, }; Session["has_pay"] = "true"; return(View(resView)); }
// GET: PurchaseCar public ActionResult Index() { if (Session["has_login"] == null) { if (Session["ReturnToPurchaseCar"] == null) { Session["ReturnToPurchaseCar"] = "true"; } else { Session["ReturnToPurchaseCar"] = null; } return(Redirect("/Login")); } else { Session.Remove("ReturnToPurchaseCar"); string phone = Session["mem_phone"].ToString(); string nowdir = savepath + phone + @"\"; string nowpath1 = nowdir + @"alipay_coder.jpg"; string nowpath2 = nowdir + @"weixin_coder.jpg"; if (System.IO.File.Exists(nowpath1)) { System.IO.File.Delete(nowpath1); } if (System.IO.File.Exists(nowpath2)) { System.IO.File.Delete(nowpath2); } ShopBusinessLogic.MemberPurchase memberPurchase = new ShopBusinessLogic.MemberPurchase(); var pcar_list = memberPurchase.getPurchaseCarList(phone).Select(pcar_info => new MemberPurchaseCarViewModel() { goods_id = pcar_info.goods_id, goods_num = pcar_info.goods_num, goods_name = memberPurchase.getGoods(pcar_info.goods_id).goods_name, goods_img_path = memberPurchase.getGoods(pcar_info.goods_id).goods_img_path, unit_price = memberPurchase.getGoods(pcar_info.goods_id).goods_price, total_price = memberPurchase.getGoods(pcar_info.goods_id).goods_price *pcar_info.goods_num, sell_stock = memberPurchase.getGoods(pcar_info.goods_id).goods_stock, }).ToList(); var resView = new MemberPurchaseCarViewModel() { mem_phone = phone, pcar_list = pcar_list, }; return(View(resView)); } }
public ActionResult Index(string DeletePcarId) { Session.Remove("ReturnToPurchaseCar"); string mem_phone = Session["mem_phone"].ToString(); ShopBusinessLogic.MemberPurchase memberPurchase = new ShopBusinessLogic.MemberPurchase(); memberPurchase.deletePurchaseCar(mem_phone, DeletePcarId); var pcar_list = memberPurchase.getPurchaseCarList(Session["mem_phone"].ToString()).Select(pcar_info => new MemberPurchaseCarViewModel() { goods_id = pcar_info.goods_id, goods_num = pcar_info.goods_num, goods_name = memberPurchase.getGoods(pcar_info.goods_id).goods_name, goods_img_path = memberPurchase.getGoods(pcar_info.goods_id).goods_img_path, unit_price = memberPurchase.getGoods(pcar_info.goods_id).goods_price, total_price = memberPurchase.getGoods(pcar_info.goods_id).goods_price *pcar_info.goods_num, }).ToList(); var resView = new MemberPurchaseCarViewModel() { mem_phone = Session["mem_phone"].ToString(), pcar_list = pcar_list, }; return(View(resView)); }