public ActionResult MyCart2() { var dal = new MarketPlaceDAL.MarketPlaceRepository(); string userid = Session["userid"].ToString(); var cartList = dal.GetCart(userid); var cartItems = new List <Models.Cart>(); foreach (var item in cartList) { cartItems.Add(Mapper.Map <Models.Cart>(item)); } if (cartItems.Count > 0) { ViewBag.status = 1; } //List<string> cancelList = new List<string>(); //cancelList = l; string error = "Some items are out of stock."; //foreach (var item in cancelList) //{ // error = error + item.itemname + " "; //} ViewBag.error = error; return(View(cartItems)); }
public ActionResult BuyItem(FormCollection obj) { var c = new Models.Cart(); c.cartid = ""; c.itemid = obj["itemid"].ToString(); c.userid = obj["userid"].ToString(); c.quantity = Convert.ToInt32(obj["quantity"]); c.price = Convert.ToDecimal(obj["price"]) * c.quantity; c.itemname = obj["itemname"].ToString(); //return View("trial",c); var dal = new MarketPlaceDAL.MarketPlaceRepository(); string userid = c.userid; if (dal.CheckQuantity(c.itemid, c.quantity) == "Y") { int status = dal.AddToCart(Mapper.Map <MarketPlaceDAL.Cart>(c), userid); //dal.ReduceQuantity(c.itemid, c.quantity); if (status == 1) { return(RedirectToAction("MyCart")); } else { return(View("Error")); } } else { return(RedirectToAction("AddToCart2", c)); } }
public ActionResult DeleteFromCart(Models.Cart cart) { var dal = new MarketPlaceDAL.MarketPlaceRepository(); int q = Convert.ToInt32(dal.RemoveItem(cart.cartid)); // dal.IncreaseItemCount(cart.itemid, q); return(RedirectToAction("MyCart")); }
public ActionResult ViewOrder() { var dal = new MarketPlaceDAL.MarketPlaceRepository(); string userid = Session["userid"].ToString(); var orderList = dal.GetOrder(userid); var orders = new List <Models.Order>(); foreach (var item in orderList) { orders.Add(Mapper.Map <Models.Order>(item)); } return(View(orders)); }
public ActionResult CategoryIndex() { var dal = new MarketPlaceDAL.MarketPlaceRepository(); string userid = Session["userid"].ToString(); var categoryList = dal.GetCategory(userid); var categories = new List <Models.Category>(); foreach (var item in categoryList) { categories.Add(Mapper.Map <Models.Category>(item)); } return(View(categories)); }
public ActionResult ChangeStatus(Models.Category item) { try { // TODO: Add update logic here var dal = new MarketPlaceDAL.MarketPlaceRepository(); dal.UpdateStatus(item.catid); return(RedirectToAction("CategoryIndex")); } catch { return(View()); } }
public ActionResult PlaceOrder() { string userid = Session["userid"].ToString(); var dal = new MarketPlaceDAL.MarketPlaceRepository(); int cancel = dal.CheckOut(userid); if (cancel == 0) { return(View("OrderPlaced")); } else { return(RedirectToAction("MyCart2")); } }
public ActionResult MyCart() { var dal = new MarketPlaceDAL.MarketPlaceRepository(); string userid = Session["userid"].ToString(); var cartList = dal.GetCart(userid); var cartItems = new List <Models.Cart>(); foreach (var item in cartList) { cartItems.Add(Mapper.Map <Models.Cart>(item)); } if (cartItems.Count > 0) { ViewBag.status = 1; } return(View(cartItems)); }
public ActionResult EditItemDB(FormCollection obj) { // var c = new Models.CustomItem(); string itemid = obj["itemid"].ToString(); decimal price = Convert.ToDecimal(obj["price"]); int quantity = Convert.ToInt32(obj["quantity"]); //string itemid = ViewBag.itemid; //ViewBag.itemid = itemid; var dal = new MarketPlaceDAL.MarketPlaceRepository(); //string catid = dal.GetCategoryID(item.catname); //string subcatid = dal.GetSubCatID(catid, item.subcatname); //string userid = Session["userid"].ToString(); //string itemid = dal.GetItemID(catid, subcatid, userid, item.itemname); // return View("trial"); dal.UpdateItem(itemid, price, quantity); return(RedirectToAction("SellerPane")); }
public ActionResult LoginUser(FormCollection obj) { string username = obj["userid"]; string password = obj["pwd"]; var dal = new MarketPlaceDAL.MarketPlaceRepository(); int status = dal.CheckUser(username, password); if (status == 1) { System.Web.HttpContext.Current.Session["userid"] = dal.GetUserID(username); Session["username"] = username; return(View("LoginPage")); } else { return(View("WrongPassword")); } }
public ActionResult SellerPane() { var dal = new MarketPlaceDAL.MarketPlaceRepository(); string userid = Session["userid"].ToString(); var itemList = dal.GetItemSeller(userid); var customList = new List <Models.CustomItem>(); foreach (var item in itemList) { var c = new Models.CustomItem(); c.catname = dal.GetCategoryName(item.catid); c.itemname = item.name; c.itemid = item.itemid; c.price = item.price; c.quantity = item.quantity; c.subcatname = dal.GetSubCatName(item.subid); c.seller = dal.GetUserName(item.addedby); customList.Add(c); } return(View(customList)); }