public ActionResult Redirect_to_DeliveryBoy(int orderid)
 {
     if (Session["adm_email"] != null)
     {
         Ordered_Cake_Details   ordered   = DB.Ordered_Cake_Details.FirstOrDefault(id => id.Order_ID == orderid);
         Delivery_Details       delivery  = DB.Delivery_Details.FirstOrDefault(mail => mail.Email_ID == ordered.Email_ID);
         OrderDeliveryViewModel viewModel = new OrderDeliveryViewModel();
         viewModel.Order_ID         = ordered.Order_ID;
         viewModel.Email_ID         = delivery.Email_ID;
         viewModel.Customer_Name    = delivery.Customer_Name;
         viewModel.Mobile_Number    = delivery.Mobile_Number;
         viewModel.Delivery_Address = delivery.Delivery_Address;
         viewModel.Date_Of_Delivery = delivery.Date_Of_Delivery;
         viewModel.Time_Of_Delivery = delivery.Time_Of_Delivery;
         return(View(viewModel));
     }
     else
     {
         return(RedirectToAction("Admin_Login"));
     }
 }
        protected void Confirm(object sender, EventArgs e)
        {
            int orderID = Convert.ToInt32(Session["order"]);

            Delivery_Orders d = new Delivery_Orders();

            d.clerk_user   = User.Identity.Name;
            d.deleted      = "N";
            d.order_id     = orderID;
            d.receive_date = DateTime.Parse(deliverydate.Text);

            context.Delivery_Orders.Add(d);
            context.SaveChanges();

            List <Purchase_Order_Details> podList = context.Purchase_Order_Details.Where(x => x.order_id == orderID).ToList <Purchase_Order_Details>();

            foreach (Purchase_Order_Details pod in podList)
            {
                pod.status = "Completed";
                context.SaveChanges();
            }


            //Get DeliveryOrderID
            Delivery_Orders order = context.Delivery_Orders.Where(x => x.clerk_user == User.Identity.Name).OrderBy(x => x.delivery_id).ToList().Last();



            foreach (GridViewRow rows in GridView1.Rows)
            {
                TextBox qty = (TextBox)rows.FindControl("quantity");
                TextBox r   = (TextBox)rows.FindControl("remark");

                Label exp_quantity = (Label)rows.FindControl("Label_quantity");

                int exp_qty = Convert.ToInt32(exp_quantity.Text);

                Label itemdesc      = (Label)rows.FindControl("Label_itemDesc");
                Label orderdetailid = (Label)rows.FindControl("Label_OrderDetailId");

                string itemName = itemdesc.Text;
                int    quantity = Convert.ToInt32(qty.Text);


                string remarks     = r.Text;
                int    orderDetail = Convert.ToInt32(orderdetailid.Text);

                Stock_Inventory item            = context.Stock_Inventory.Where(x => x.item_description == itemName).First();
                int             currentQuantity = item.current_qty;
                item.current_qty = currentQuantity + quantity;
                context.SaveChanges();

                Purchase_Order_Details pod = context.Purchase_Order_Details.Where(x => x.order_details_id == orderDetail).First();

                Delivery_Details dd = new Delivery_Details();
                dd.delivery_id = order.delivery_id;
                dd.deleted     = "N";
                dd.tender_id   = pod.tender_id;
                dd.quantity    = quantity;
                dd.remarks     = remarks;

                context.Delivery_Details.Add(dd);
                context.SaveChanges();
            }


            Response.Redirect("~/views/storeclerk/viewpendingorder.aspx");
        }