public ActionResult SupplierEditOrder(SupplierUpdateOrderViewModel item, string ConfirmationCode)
        {
            try
            {
                string userId = User.Identity.GetUserId();
                if (userId == null)
                {
                    return RedirectToAction("Login", "Account");
                }
                if (User.IsInRole("Supplier"))
                {
                    //Retrieve the Order details from database
                    //Store it in variable Order
                    var order = (from o in db.Orders
                                 where o.OrderId == item.OrderId
                                 select o).FirstOrDefault();

                    //ViewBag.OrderStatusId = new SelectList(db.OrderStatuses, "OrderStatusId", "Name", item.OrderStatusId);

                    //order.Status = (from os in db.OrderStatuses
                    //                where os.OrderStatusId == item.OrderStatusId
                    //                select os.Name).FirstOrDefault();

                    //Store the orderStatus in variable orderStatus
                    string orderStatus = order.Status.ToString();

                    //Verify if Order has status Active
                    if (orderStatus == "Active")
                    {
                        //Set Order Status to Processing
                        order.Status = "Processing";
                    }

                    //Verify if Order has status Processing
                    if (orderStatus == "Processing")
                    {
                        //Set Order Status to Processing
                        order.Status = "In Transit";
                    }

                    //Verify if Order has status In Transit
                    if (orderStatus == "In Transit")
                    {
                        //Retrieve code from form
                        //Store it in variable SupplierCode
                        string SupplierCode = ConfirmationCode.ToString();

                        //Retrieve the actual Confirmation Code from database
                        //Store it in variable CustomerCode
                        string CustomerCode = (from o in db.Orders
                                               where o.OrderId == order.OrderId
                                               select o.ConfirmationCode).FirstOrDefault();

                        //Verify if SupplierCode matches with CustomerCode
                        if (SupplierCode == CustomerCode)
                        {
                            //Set Order Status to Processing
                            order.Status = "Delivered";

                            //Set Order Notification to Customer
                            //so that Customer gets notified about the Update
                            order.Notification = "Customer";
                            order.CommissionPaid = false;

                            //Save changes made to the database
                            db.SaveChanges();

                            //Redirect to SupplierRetrieveOrders View with a route value
                            return RedirectToAction("SupplierRetrieveOrders", "Supplier", new { message = ManageMessageId.OrderDeliveredSuccess });
                        }
                        else return RedirectToAction("SupplierRetrieveOrders", "Supplier", new { message = ManageMessageId.ConfirmationFailure });
                    }

                    order.Notification = "Customer";
                    db.SaveChanges();

                    GetSupplierReturnNotification();
                    GetSupplierNotification();
                    return RedirectToAction("SupplierRetrieveOrders", "Supplier", new { message = ManageMessageId.UpdateOrderStatus });
                }
                if (User.IsInRole("Admin"))
                {
                    return RedirectToAction("Index", "Admin");
                }
                return RedirectToAction("Error404", "Home");
            }
            catch (Exception ex)
            {
                return new HttpStatusCodeResult(HttpStatusCode.InternalServerError, ex.ToString());
            }
        }
        public ActionResult SupplierEditOrder(int id)
        {
            try
            {
                string userId = User.Identity.GetUserId();
                if (userId == null)
                {
                    return RedirectToAction("Login", "Account");
                }
                if (User.IsInRole("Supplier"))
                {
                    var record = (from o in db.Orders
                                  where o.OrderId == id
                                  select o).FirstOrDefault();
                    var order = new SupplierUpdateOrderViewModel()
                    {
                        OrderId = record.OrderId,
                        DtCreated = record.DtCreated,
                        ExpectedDeliveryDate = record.ExpectedDeliveryDate,
                        RealDeliveryDate = record.RealDeliveryDate,
                        Total = record.Total,
                        GrandTotal = record.GrandTotal,
                        CustomerName = (from c in db.Customers
                                        where c.CustomerId == record.CustomerId
                                        select c.Name).FirstOrDefault(),
                        Status = record.Status
                    };

                    ViewBag.OrderStatusId = new SelectList(db.OrderStatuses, "OrderStatusId", "Name");

                    GetSupplierReturnNotification();
                    GetSupplierNotification();
                    return View(order);
                }
                return RedirectToAction("Login", "Account");
            }
            catch (Exception ex)
            {
                return new HttpStatusCodeResult(HttpStatusCode.InternalServerError, ex.ToString());
            }
        }