public ActionResult Insert(string phoneID1, string phoneName1, string description1, string quantity1, string price1, string discount1, string supID1) { double discount = 0; if (discount1.Length > 0) { discount = double.Parse(discount1); } PhoneDAO dao = new PhoneDAO(); PhotoPhoneDAO daoPhoto = new PhotoPhoneDAO(); bool result = dao.Insert(new Phone() { phoneID = phoneID1, phoneName = phoneName1, description = description1, price = double.Parse(price1), quantity = int.Parse(quantity1), discount = discount, supID = supID1, status = true }); for (int i = 0; i < Request.Files.Count; i++) { HttpPostedFileBase f = Request.Files[i]; if (f.ContentLength > 0) { daoPhoto.Insert(new PhotoPhone() { urlPhoto = "/Image/" + f.FileName, phoneID = phoneID1 }); f.SaveAs(Server.MapPath("~/Image/") + f.FileName); } } return(RedirectToAction("Index", "ManageMobile")); }
public ActionResult Delete(string phoneID) { PhoneDAO dao = new PhoneDAO(); dao.Delete(phoneID); return(RedirectToAction("Index", "ManageMobile")); }
public ActionResult Update(Phone phone) { PhoneDAO dao = new PhoneDAO(); PhotoPhoneDAO daoPhoto = new PhotoPhoneDAO(); dao.Update(phone); if (Request.Files[0].ContentLength > 0) { daoPhoto.DeletePhotoOfPhone(phone.phoneID); for (int i = 0; i < Request.Files.Count; i++) { HttpPostedFileBase f = Request.Files[i]; if (f.ContentLength > 0) { daoPhoto.Insert(new PhotoPhone() { urlPhoto = "/Image/" + f.FileName, phoneID = phone.phoneID }); f.SaveAs(Server.MapPath("~/Image/") + f.FileName); } } } return(RedirectToAction("Index", "ManageMobile")); }
public ActionResult Checkout(string receiver, string phone, string address) { User user = (User)Session["USER"]; if (user != null) { CartObj cart = (CartObj)Session["CART"]; if (cart != null) { DateTime date = DateTime.Now; OrderDAO daoOrder = new OrderDAO(); OrderDetailsDAO daoDetails = new OrderDetailsDAO(); Order order = new Order() { phone = phone, receiver = receiver, addressShip = address, username = user.username, orderDate= date}; daoOrder.Add(order); int currentID = daoOrder.GetCurrentOrderID(); foreach(var item in cart.cart) { OrderDetail details = new OrderDetail() { orderID = currentID, phoneID = item.Key.phoneID, price = item.Key.price, quantity = item.Value, discount = item.Key.discount }; daoDetails.Add(details); PhoneDAO daoPhone = new PhoneDAO(); daoPhone.UpdateQuantity(item.Value,item.Key.phoneID); } Session["CART"] = null; } } return RedirectToAction("Index", "Home", new { area = "" }); }
// GET: Shopping public ActionResult Index() { PhoneDAO dao = new PhoneDAO(); Session["MANAGE"] = "Shop"; ViewData["PHONE"] = dao.GetAllCurrentPhone(); return(View()); }
// GET: Details public ActionResult Index(string phoneID) { PhoneDAO dao = new PhoneDAO(); Phone phone = dao.GetPhone(phoneID); ViewData["PHONE"] = phone; return(View()); }
public static Phone MapToPhone(PhoneDAO phone) { var p = new Phone(); p.PhoneID = phone.Id; p.PhoneNumber = phone.Number; p.Active = phone.Active; return(p); }
public static PhoneDAO MapToPhoneDAO(Phone phone) { var p = new PhoneDAO(); p.Id = phone.PhoneID; p.Number = phone.PhoneNumber; p.Active = phone.Active; return(p); }
public static PhoneDTO MapToDTO(PhoneDAO phone) { var p = new PhoneDTO(); p.Id = phone.Id; p.Number = phone.Number; p.Active = phone.Active; return(p); }
// GET: Home public ActionResult Index() { PhoneDAO dao = new PhoneDAO(); SupplierDAO daoSup = new SupplierDAO(); ViewData["PHONE"] = dao.GetLastestPhone(); ViewData["SUPPLIER"] = daoSup.GetAllSupplier(); Session["MANAGE"] = "Home"; return(View()); }
public ActionResult ViewBySupplier(string supID) { PhoneDAO dao = new PhoneDAO(); SupplierDAO daoSup = new SupplierDAO(); Session["MANAGE"] = "Shop"; ViewData["SUPPLIER"] = daoSup.GetSupplier(supID); ViewData["PHONE"] = dao.GetAllCurrentPhoneBySup(supID); return(View("Index")); }
public ActionResult ViewUpdate(string phoneID) { SupplierDAO dao = new SupplierDAO(); PhotoPhoneDAO daoPhoto = new PhotoPhoneDAO(); PhoneDAO daoPhone = new PhoneDAO(); ViewData["SUPPLIER_LIST"] = dao.GetAllSupplier(); ViewData["UPDATE"] = daoPhone.GetPhone(phoneID); ViewData["PHOTO"] = daoPhoto.GetPhotoOfPhone(phoneID); return(View()); }
// GET: Admin/ManageMobile public ActionResult Index() { Session["MANAGE"] = "Mobile"; PhoneDAO daoPhone = new PhoneDAO(); SupplierDAO daoSup = new SupplierDAO(); List <Phone> listMobile = daoPhone.GetAllPhone(); List <Supplier> listSupplier = daoSup.GetAllSupplier(); ViewData["All_MOBILE"] = listMobile; ViewData["All_Supplier"] = listSupplier; return(View()); }
public JsonResult CheckDupMobileID(string phoneID) { System.Threading.Thread.Sleep(1500); PhoneDAO dao = new PhoneDAO(); Phone phone = dao.GetPhone(phoneID); if (phone != null) { return(Json(1)); } else { return(Json(0)); } }
public ActionResult UpdateQuantity(FormCollection col) { string id = col["id"]; string quantity = col["quantity"]; Order cart = Session["CART"] as Order; PhoneDAO dao = new PhoneDAO(); bool isEnough = true; string name = "bủh"; for (int i = 0; i < cart.detailList.Count; i++) { if (cart.detailList[i].IDProduct.Equals(id)) { if (cart.detailList[i].Quantity > dao.GetProductDetail(cart.detailList[i].IDProduct).Quantity) { isEnough = false; name = cart.detailList[i].ProductName; } } } if (!isEnough) { ViewBag.INSUFF = "There is not enough quantity of " + name + " for you! Please choose another products or decrease the amount!"; } else { for (int i = 0; i < cart.detailList.Count; i++) { if (cart.detailList[i].IDProduct.Equals(id)) { cart.detailList[i].Quantity = Convert.ToInt32(quantity); } } int total = 0; for (int i = 0; i < cart.detailList.Count; i++) { total += (cart.detailList[i].Price * cart.detailList[i].Quantity); } cart.Total = total; Session["CART"] = cart; } return(View("ViewCart")); }
public JsonResult UpdateCart(string phoneID, int value) { PhoneDAO dao = new PhoneDAO(); Phone phone = dao.GetPhone(phoneID); CartObj cart = (CartObj)Session["CART"]; if (cart == null) { cart = new CartObj(); } cart.UpdateCart(phoneID, value); Session["CART"] = cart; List <dynamic> x = new List <dynamic>(); x.Add(cart.cart.Count); x.Add(cart.total); x.Add(cart.cart[phone] * phone.price); return(Json(x)); }
public JsonResult AddToCartWithValue(string phoneID, int value) { PhoneDAO dao = new PhoneDAO(); Phone p = dao.GetPhone(phoneID); CartObj cart = (CartObj)Session["CART"]; if (cart == null) { cart = new CartObj(); } cart.AddToCart(phoneID, value); Session["CART"] = cart; List <dynamic> x = new List <dynamic>(); x.Add(cart.cart.Count); x.Add(cart.total); x.Add(p.quantity - cart.cart[p]); return(Json(x)); }
public static List <Phone> Search(string valueToFind) { return(PhoneDAO.Search(valueToFind)); }
public static List <PhoneDTO> GetPhones() { return(PhoneDAO.GetPhones()); }
public static Phone GetSinglePhone(int ID) { return(PhoneDAO.GetSinglePhone(ID)); }
public static Phone GetSinglePhone(int ID, string IDLoaiSanPham) { return(PhoneDAO.GetSinglePhone(ID, IDLoaiSanPham)); }
public bool DeletePhone(PhoneDAO phone) { return(data.DeletePhone(PhoneMapper.MapToPhone(phone))); }
public bool InsertPhone(PhoneDAO phone) { return(data.InsertPhone(PhoneMapper.MapToPhone(phone))); }
public static List <PhoneDTO> GetAllPhone() { return(PhoneDAO.GetALLPhone()); }
public static List <Phone> GetAll() { return(PhoneDAO.GetAll()); }
public static bool InsertIntoPhone(Phone phone) { return(PhoneDAO.InsertIntoPhone(phone)); }
public static bool UpdateIntoPhone(Phone phone) { return(PhoneDAO.UpdateIntoPhone(phone)); }
public ActionResult ConfirmCart() { Order cart = Session["CART"] as Order; PhoneDAO dao = new PhoneDAO(); bool isEnough = true; string name = "bủh"; CartDAO cartDAO = new CartDAO(); for (int i = 0; i < cart.detailList.Count; i++) { if (cart.detailList[i].Quantity > dao.GetProductDetail(cart.detailList[i].IDProduct).Quantity) { isEnough = false; name = cart.detailList[i].ProductName; } } if (!isEnough) { ViewBag.INSUFF = "There is not enough quantity of " + name + " for you! Please choose another products or decrease the amount!"; return(View("ViewCart")); } else { bool isCartOk = cartDAO.AddCart(cart); PhoneDAO phoneDao = new PhoneDAO(); bool isAllOk = true; if (isCartOk) { bool[] isDetailsOk = new bool[cart.detailList.Count]; bool[] isUpdateOk = new bool[cart.detailList.Count]; for (int i = 0; i < isDetailsOk.Length; i++) { isDetailsOk[i] = cartDAO.AddOrder(cart.detailList[i]); } for (int i = 0; i < isDetailsOk.Length; i++) { Product p = new Product(cart.detailList[i].IDProduct, cart.detailList[i].Store - cart.detailList[i].Quantity); isUpdateOk[i] = phoneDao.UpdateProductAfterAddCart(p); } for (int i = 0; i < isDetailsOk.Length; i++) { if (!isDetailsOk[i]) { isAllOk = false; } } for (int i = 0; i < isUpdateOk.Length; i++) { if (!isUpdateOk[i]) { isAllOk = false; } } if (!isAllOk) { return(Redirect(Url.Action("Error", "Phone"))); } else { Session.Remove("CART"); return(Redirect(Url.Action("LoadList", "Phone"))); } } else { return(Redirect(Url.Action("Error", "Phone"))); } } }
public static bool DeleteIntoPhone(int ID) { return(PhoneDAO.DeleteIntoPhone(ID)); }
public bool ChangePhone(PhoneDAO phone) { return(data.ChangePhone(PhoneMapper.MapToPhone(phone))); }