public async Task<ActionResult> AddDetails(OrderScheduleViewModel myOrderSchedule)
        {
            if (ModelState.IsValid)
            {

                ProjectMethods.SaveOrderSchedule(myOrderSchedule);
                return RedirectToAction("Index");
            }
             
            return View(myOrderSchedule);
        }
        public static OrderScheduleViewModel GetOrderSchedulebyId(int? id)
        {
            var db = new IstokDoorsDBContext();
            var myOrderSchedule = db.usp_GetOrderScheduleById(id).Single();
            //TODO: Don't forget to add Single method to materialize the object!!!

            var myOrderScheduleViewModel = new OrderScheduleViewModel();

            myOrderScheduleViewModel.OrderId = myOrderSchedule.OrderId;
            myOrderScheduleViewModel.FactoryName = myOrderSchedule.FactoryName;
            myOrderScheduleViewModel.FactoryId = myOrderSchedule.FactoryId??1;
            myOrderScheduleViewModel.DateOfCreation = myOrderSchedule.DateOfCreation;
            myOrderScheduleViewModel.DateEntryToFactory = myOrderSchedule.DateEntryToFactory;
            myOrderScheduleViewModel.PlannedDateOfManufacture = myOrderSchedule.PlannedDateOfManufactoring;
            myOrderScheduleViewModel.PlannedDateOfShipping = myOrderSchedule.PlannedDateOfShipping;
            myOrderScheduleViewModel.ActualDateOfManufacture = myOrderSchedule.ActualDateOfManufactoring;
            myOrderScheduleViewModel.ActualDateOfShipping = myOrderSchedule.ActualDateOfShipping;

            return myOrderScheduleViewModel;

        }
        public static void SaveOrderSchedule(OrderScheduleViewModel myOrderScheduleViewModel)
        {
            var db = new IstokDoorsDBContext();

            var myOrderScheduleMvc = db.OrderFulfillmentSchedules.Find(myOrderScheduleViewModel.OrderId);


            myOrderScheduleMvc.DateEntryToFactory = myOrderScheduleViewModel.DateEntryToFactory;
            myOrderScheduleMvc.PlannedDateOfManufactoring = myOrderScheduleViewModel.PlannedDateOfManufacture;
            myOrderScheduleMvc.PlannedDateOfShipping = myOrderScheduleViewModel.PlannedDateOfShipping;
            myOrderScheduleMvc.ActualDateOfManufactoring = myOrderScheduleViewModel.ActualDateOfManufacture;
            myOrderScheduleMvc.ActualDateOfShipping = myOrderScheduleViewModel.ActualDateOfShipping;

            db.SaveChanges();

        }
        public static List<OrderScheduleViewModel> ConvertListsForOrdersScheduleStatus4_5()
        {
            var db = new IstokDoorsDBContext();
            var myOrders = db.usp_GetOrdersSchedule().ToList();
            var myList = new List<OrderScheduleViewModel>();

            foreach (var item in myOrders)
            {

                var myOrder = new OrderScheduleViewModel();
                if (item.OrderStatusId > 3)
                {
                    myOrder.OrderId = item.OrderId;
                    myOrder.FactoryName = item.FactoryName;
                    myOrder.DateEntryToFactory = item.DateEntryToFactory;
                    myOrder.ActualDateOfManufacture = item.ActualDateOfManufactoring;
                    myOrder.PlannedDateOfManufacture = item.PlannedDateOfShipping;
                    myOrder.PlannedDateOfShipping = item.PlannedDateOfShipping;
                    myOrder.ActualDateOfShipping = item.ActualDateOfShipping;
                    myOrder.DateOfCreation = item.DateOfCreation;


                    myList.Add(myOrder);
                }

            }


            return myList;
        }