Esempio n. 1
0
        public ActionResult Index()
        {
            try
            {
                int CompanyId = Convert.ToInt32(Session["CompanyId"]);

                if (CompanyId < 1)
                {
                    return(RedirectToAction("Create", "Company"));
                }
                else
                {
                    if (HttpContext.Cache["customerNotificationViewModels"] == null)
                    {
                        var result = webServices.Post(new CustomerNotificationViewModel(), "Advertisement/All");

                        if (result.StatusCode == System.Net.HttpStatusCode.Accepted)
                        {
                            if (result.Data != null)
                            {
                                customerNotificationViewModels = (new JavaScriptSerializer().Deserialize <List <CustomerNotificationViewModel> >(result.Data.ToString()));
                                HttpContext.Cache["customerNotificationViewModels"] = customerNotificationViewModels;
                            }
                        }
                    }
                    else
                    {
                        customerNotificationViewModels = HttpContext.Cache["customerNotificationViewModels"] as List <CustomerNotificationViewModel>;
                    }
                    ViewBag.customerNotificationViewModels = customerNotificationViewModels;

                    SearchViewModel searchViewModel = new SearchViewModel();
                    searchViewModel.CompanyId = Convert.ToInt32(Session["CompanyId"]);

                    var resultCustomerStatistics = webServices.Post(searchViewModel, "CustomerOrder/CustomerStatistics");
                    if (resultCustomerStatistics.StatusCode == System.Net.HttpStatusCode.Accepted)
                    {
                        customerOrderStatistics = (new JavaScriptSerializer().Deserialize <CustomerOrderStatistics>(resultCustomerStatistics.Data.ToString()));
                    }
                    ViewBag.customerOrderStatistics = customerOrderStatistics;

                    var RequestedData = customerOrderStatistics.RequestedBySevenDayed;

                    Session["RequestedData"] = RequestedData;

                    return(View());
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 2
0
        public ActionResult AdminHome()
        {
            try
            {
                if (HttpContext.Cache["customerNotificationViewModels"] == null)
                {
                    var result = webServices.Post(new CustomerNotificationViewModel(), "Advertisement/All");

                    if (result.StatusCode == System.Net.HttpStatusCode.Accepted)
                    {
                        if (result.Data != null)
                        {
                            customerNotificationViewModels = (new JavaScriptSerializer().Deserialize <List <CustomerNotificationViewModel> >(result.Data.ToString()));
                            HttpContext.Cache["customerNotificationViewModels"] = customerNotificationViewModels;
                        }
                    }
                }
                else
                {
                    customerNotificationViewModels = HttpContext.Cache["customerNotificationViewModels"] as List <CustomerNotificationViewModel>;
                }
                ViewBag.customerNotificationViewModels = customerNotificationViewModels;

                SearchViewModel searchViewModel = new SearchViewModel();
                searchViewModel.CompanyId = Convert.ToInt32(Session["CompanyId"]);

                var resultCustomerStatistics = webServices.Post(searchViewModel, "CustomerOrder/AdminStatistics");
                if (resultCustomerStatistics.StatusCode == System.Net.HttpStatusCode.Accepted)
                {
                    customerOrderStatistics = (new JavaScriptSerializer().Deserialize <CustomerOrderStatistics>(resultCustomerStatistics.Data.ToString()));
                }
                ViewBag.customerOrderStatistics = customerOrderStatistics;

                return(View());
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 3
0
        public ActionResult Index()
        {
            var fuelPricesViewModels = new List <FuelPricesViewModel>();

            try
            {
                int CompanyId = Convert.ToInt32(Session["CompanyId"]);

                if (CompanyId < 1)
                {
                    return(RedirectToAction("Create", "Company"));
                }
                else
                {
                    if (HttpContext.Cache["customerNotificationViewModels"] == null)
                    {
                        var result = webServices.Post(new CustomerNotificationViewModel(), "Advertisement/All");

                        if (result.StatusCode == System.Net.HttpStatusCode.Accepted)
                        {
                            if (result.Data != null)
                            {
                                customerNotificationViewModels = (new JavaScriptSerializer().Deserialize <List <CustomerNotificationViewModel> >(result.Data.ToString()));
                                HttpContext.Cache["customerNotificationViewModels"] = customerNotificationViewModels;
                            }
                        }
                    }
                    else
                    {
                        customerNotificationViewModels = HttpContext.Cache["customerNotificationViewModels"] as List <CustomerNotificationViewModel>;
                    }
                    ViewBag.customerNotificationViewModels = customerNotificationViewModels;

                    SearchViewModel searchViewModel = new SearchViewModel
                    {
                        CompanyId = Convert.ToInt32(Session["CompanyId"])
                    };
                    var resultCustomerStatistics = webServices.Post(searchViewModel, "CustomerOrder/CustomerStatistics");
                    if (resultCustomerStatistics.StatusCode == System.Net.HttpStatusCode.Accepted)
                    {
                        customerOrderStatistics = (new JavaScriptSerializer().Deserialize <CustomerOrderStatistics>(resultCustomerStatistics.Data.ToString()));
                    }
                    ViewBag.customerOrderStatistics = customerOrderStatistics;

                    FuelPricesViewModel fuelPricesViewModel = new FuelPricesViewModel();

                    var resultFuel = webServices.Post(fuelPricesViewModel, "FuelPrices/FuelPricesTopOne");
                    if (resultFuel.StatusCode == System.Net.HttpStatusCode.Accepted)
                    {
                        fuelPricesViewModels = (new JavaScriptSerializer().Deserialize <List <FuelPricesViewModel> >(resultFuel.Data.ToString()));
                    }
                    ViewBag.fuelPricesViewModel  = fuelPricesViewModels[0];
                    ViewBag.fuelPricesViewModels = fuelPricesViewModels;

                    var RequestedData        = customerOrderStatistics.RequestedBySevenDayed;
                    var userCompanyViewModel = new UserCompanyViewModel();
                    Session["RequestedData"] = RequestedData;
                    userCompanyViewModel     = Session["userCompanyViewModel"] as UserCompanyViewModel;

                    if (userCompanyViewModel != null)
                    {
                        TempData["Title"] = userCompanyViewModel.CompanyName ?? "Unknown";
                    }

                    return(View());
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 4
0
        public ActionResult AdminHome()
        {
            try
            {
                if (HttpContext.Cache["customerNotificationViewModels"] == null)
                {
                    var result = webServices.Post(new CustomerNotificationViewModel(), "Advertisement/All");

                    if (result.StatusCode == System.Net.HttpStatusCode.Accepted)
                    {
                        if (result.Data != null)
                        {
                            customerNotificationViewModels = (new JavaScriptSerializer().Deserialize <List <CustomerNotificationViewModel> >(result.Data.ToString()));
                            HttpContext.Cache["customerNotificationViewModels"] = customerNotificationViewModels;
                        }
                    }
                }
                else
                {
                    customerNotificationViewModels = HttpContext.Cache["customerNotificationViewModels"] as List <CustomerNotificationViewModel>;
                }
                ViewBag.customerNotificationViewModels = customerNotificationViewModels;

                SearchViewModel searchViewModel = new SearchViewModel
                {
                    CompanyId = Convert.ToInt32(Session["CompanyId"])
                };
                var resultCustomerStatistics = webServices.Post(searchViewModel, "CustomerOrder/AdminStatistics");
                if (resultCustomerStatistics.StatusCode == System.Net.HttpStatusCode.Accepted)
                {
                    if (resultCustomerStatistics.Data != null)
                    {
                        customerOrderStatistics = (new JavaScriptSerializer().Deserialize <CustomerOrderStatistics>(resultCustomerStatistics.Data.ToString()));
                    }
                }
                ViewBag.customerOrderStatistics = customerOrderStatistics;

                //Storage details
                List <StorageDetailsViewModel> storageDetailsViewModels = new List <StorageDetailsViewModel>();
                var resultStorage = webServices.Post(new StorageDetailsViewModel(), "Storage/StorageAllDetails");
                if (resultStorage.StatusCode == System.Net.HttpStatusCode.Accepted)
                {
                    if (resultStorage.Data != null)
                    {
                        storageDetailsViewModels = (new JavaScriptSerializer().Deserialize <List <StorageDetailsViewModel> >(resultStorage.Data.ToString()));
                    }
                }
                ViewBag.storageDetailsViewModels = storageDetailsViewModels;

                //Booking details
                List <BookingDetailsViewModel> bookingDetailsViewModels = new List <BookingDetailsViewModel>();
                var resultBooking = webServices.Post(new BookingDetailsViewModel(), "CustomerBooking/BookingAllDetails");
                if (resultBooking.StatusCode == System.Net.HttpStatusCode.Accepted)
                {
                    if (resultStorage.Data != null)
                    {
                        bookingDetailsViewModels = (new JavaScriptSerializer().Deserialize <List <BookingDetailsViewModel> >(resultBooking.Data.ToString()));
                    }
                }
                ViewBag.bookingDetailsViewModels = bookingDetailsViewModels;

                List <FuelPricesViewModel> fuelPricesViewModels = new List <FuelPricesViewModel>();
                var resultFuel = webServices.Post(new FuelPricesViewModel(), "FuelPrices/FuelPricesTopOne");
                if (resultFuel.StatusCode == System.Net.HttpStatusCode.Accepted)
                {
                    if (resultFuel.Data != null)
                    {
                        fuelPricesViewModels = (new JavaScriptSerializer().Deserialize <List <FuelPricesViewModel> >(resultFuel.Data.ToString()));
                    }
                }
                ViewBag.fuelPricesViewModel  = fuelPricesViewModels[0];
                ViewBag.fuelPricesViewModels = fuelPricesViewModels;
                return(View());
            }
            catch (Exception)
            {
                throw;
            }
        }