public ActionResult Create(OrderItem orderitem, int customerSiteNo)
        {
            if (db.OrderItems.Count() == 0)
            {
                orderitem.orderNo = 1001;
            }
            else
            {
                var lastId = db.OrderItems.Max(item => item.orderNo);
                var newId = lastId + 1;
                orderitem.orderNo = newId;
            }
            var site = db.CustomerSites.First(x => x.customerSiteNo == customerSiteNo);
            orderitem.customerSiteNo = site.customerSiteNo;

            if (orderitem.extraDeliveryStreet == null)
            {
                orderitem.extraDeliveryStreet = site.postalStreet;
                orderitem.extraDeliveryPostal = site.postalPostal;
                orderitem.extraDeliveryCity = site.postalCity;
                orderitem.extraDeliveryCountry = site.postalCountry;
            }

            orderitem.orderStatus = 1;

            ModelState.Remove("orderNo");
            ModelState.Remove("customerSiteNo");
            ModelState.Remove("orderStatus");
            if (ModelState.IsValid)
            {
                orderitem.dateOfOrder = DateTime.Now;
                site.dateOfTheLastSale = DateTime.Now;
                db.OrderItems.Add(orderitem);
                db.SaveChanges();
                return RedirectToAction("Details", new { id = orderitem.orderNo });
            }

            ViewBag.customerSiteNo = customerSiteNo;
            ViewBag.customerSiteName = site.customerSiteName;
            return View(orderitem);
        }
        public ActionResult Edit(OrderItem orderitem)
        {
            if (ModelState.IsValid)
            {

                if (db.OrderStatus.Find(orderitem.orderStatus).orderDelivered == true)
                {
                    decimal totalSum = 0;

                    foreach (var row in orderitem.OrderRows)
                    {
                        totalSum += row.salesPrice * row.orderedQuantity;
                    }
                    orderitem.CustomerSite.sales += totalSum;
                    orderitem.dateOfDelivery = DateTime.Now;
                }
                db.Entry(orderitem).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Details", new { id = orderitem.orderNo });
            }
            ViewBag.customerSiteNo = orderitem.customerSiteNo;
            ViewBag.orderStatus = new SelectList(db.OrderStatus, "orderStatusNo", "orderStatusText",
                orderitem.orderStatus);
            return View(orderitem);
        }