public ActionResult deleteshoporder(int shoporderid)
        {
            shoporder h = (from hh in db.shoporders
                           where hh.shoporderid == shoporderid
                           select hh).Single();

            db.shoporders.Remove(h);
            db.SaveChanges();
            return(RedirectToAction("shoporder"));
        }
Beispiel #2
0
        public ActionResult setdelivery(int shoporderid)
        {
            shoporder q = (from so in db.shoporders

                           where so.shoporderid == shoporderid
                           select so).First();

            q.status = "Delivered";
            db.SaveChanges();
            return(RedirectToAction("shoporder"));
        }
        public ActionResult buynow()
        {
            List <orderitem> olist = (List <orderitem>)Session["cart"];

            var q = from o in olist
                    join p in db.productdetails on o.productcode equals p.productcode
                    join ps in db.productstocks on p.product_stock_id equals ps.productstockid
                    select new JointModels {
                Orderitem = o, Productdetail = p, PStock = ps
            };

            int totalamount = 0;

            foreach (var it in q)
            {
                totalamount += (int)(it.Orderitem.quantity * it.Productdetail.price);
            }

            String email = Session["username"].ToString();

            int shopid = db.shops.Single(s => s.email == email).shopid;

            int orderid = DateTime.Now.Millisecond + shopid;

            shoporder order = new shoporder();

            order.shoporderid  = orderid;
            order.date         = DateTime.Now;
            order.total_amount = totalamount;
            order.status       = "order";
            order.remarks      = "";
            order.shopid       = shopid;

            db.shoporders.Add(order);
            foreach (var it in q)
            {
                orderitem item = new orderitem();
                item.productcode = it.Orderitem.productcode;
                item.quantity    = it.Orderitem.quantity;
                item.total       = (int)(it.Orderitem.quantity * it.Productdetail.price);
                item.shoporderid = orderid;
                db.orderitems.Add(item);
            }
            db.SaveChanges();
            Session["cart"] = null;
            return(RedirectToAction("showorders"));
        }
        public ActionResult editshoporderAction(int shoporderid, int shopid, DateTime date, string status, string remarks)
        {
            try
            {
                shoporder h = (from j in db.shoporders where j.shoporderid == shoporderid select j).Single();
                h.date    = date;
                h.status  = status;
                h.remarks = remarks;

                db.SaveChanges();
                TempData["message"] = "Succesfully updated";
            }
            catch (Exception ex)
            {
                TempData["message"] = ex.Message;
            }
            return(RedirectToAction("shoporder"));
        }
 public ActionResult Saveshoporder(DateTime date, int total_amount, string status, string remarks)
 {
     try
     {
         shoporder h = new shoporder();
         h.date         = date;
         h.total_amount = total_amount;
         h.status       = status;
         h.remarks      = remarks;
         db.shoporders.Add(h);
         db.SaveChanges();
         TempData["message"] = "Succesfully added";
     }
     catch (Exception ex)
     {
         TempData["message"] = ex.Message;
     }
     return(RedirectToAction("shoporder"));
 }