示例#1
0
        public ActionResult Create(FuelPricesViewModel fuelPricesViewModel)
        {
            try
            {
                var priceResult = new ServiceResponseModel();
                if (fuelPricesViewModel.Id < 1)
                {
                    fuelPricesViewModel.CreatedBy = Convert.ToInt32(Session["UserId"]);
                    priceResult = webServices.Post(fuelPricesViewModel, "FuelPrices/Add");
                }
                else
                {
                    fuelPricesViewModel.UpdatedBy = Convert.ToInt32(Session["UserId"]);
                    priceResult = webServices.Post(fuelPricesViewModel, "FuelPrices/Update");
                }

                if (priceResult.StatusCode == System.Net.HttpStatusCode.Accepted)
                {
                    var reuslt = (new JavaScriptSerializer().Deserialize <int>(priceResult.Data));
                    return(RedirectToAction(nameof(Index)));
                }

                return(View(fuelPricesViewModel));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#2
0
        public ActionResult Details(int Id)
        {
            try
            {
                FuelPricesViewModel.Id = Id;
                var FuelResult = webServices.Post(FuelPricesViewModel, "FuelPrices/Edit");

                if (FuelResult.StatusCode == System.Net.HttpStatusCode.Accepted)
                {
                    FuelPricesViewModel = (new JavaScriptSerializer().Deserialize <FuelPricesViewModel>(FuelResult.Data.ToString()));
                }
                var producUnittList = webServices.Post(new ProductViewModel(), "ProductUnit/All");

                if (producUnittList.StatusCode == System.Net.HttpStatusCode.Accepted)
                {
                    productUnitViewModels = (new JavaScriptSerializer().Deserialize <List <ProductUnitViewModel> >(producUnittList.Data.ToString()));
                }

                if (Request.IsAjaxRequest())
                {
                    return(Json(FuelPricesViewModel, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    ViewBag.productUnitViewModels = productUnitViewModels;
                    return(View(FuelPricesViewModel));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#3
0
        public PriceList AddNewPriceList(FuelPricesViewModel fuelPriceViewModel) //todo to chyba powinien byc serwis domenowy
        {
            var priceList = PriceList.Factory.Create("", fuelPriceViewModel.FuelPriceMinNetto, fuelPriceViewModel.FuelPriceMaxNetto, fuelPriceViewModel.FuelPriceMinBrutto, fuelPriceViewModel.FuelPriceMaxBrutto);

            priceList.Validate();
            priceList.Add();
            return(priceList);
        }
示例#4
0
        public ActionResult ChangeStatus(FuelPricesViewModel fuelPricesViewModel)
        {
            try
            {
                var Result = new ServiceResponseModel();

                fuelPricesViewModel.UpdatedBy = Convert.ToInt32(Session["UserId"]);
                Result = webServices.Post(fuelPricesViewModel, "FuelPrices/FuelPriceUpdateStatus");

                if (Result.StatusCode == System.Net.HttpStatusCode.Accepted)
                {
                    var reuslt = (new JavaScriptSerializer().Deserialize <int>(Result.Data));
                }
                return(Json("success", JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json("Failed", JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult FuelPrices()
        {
            List <FuelPricesViewModel> fuels = new List <FuelPricesViewModel>();
            FuelPricesViewModel        fuel  = new FuelPricesViewModel
            {
                CurrencyName          = "test",
                Id                    = 1,
                DeliveryMaxValue      = 100,
                DeliveryMinValue      = 120,
                FuelPriceMaxBrutto    = 40,
                FuelPriceMinNetto     = 30,
                FormOfCooperationName = "b2b",
                FuelPriceMaxNetto     = 80,
                FuelPriceMinBrutto    = 70,
                DeliveryCombinedValue = "100 - 200",
                Rebate                = 30,
                UGM                   = 3
            };

            fuels.Add(new FuelPricesViewModel
            {
                CurrencyName          = "test",
                Id                    = 1,
                DeliveryMaxValue      = 100,
                DeliveryMinValue      = 120,
                FuelPriceMaxBrutto    = 40,
                FuelPriceMinNetto     = 30,
                FormOfCooperationName = "b2b",
                FuelPriceMaxNetto     = 80,
                FuelPriceMinBrutto    = 70,
                DeliveryCombinedValue = "100 - 200",
                Rebate                = 30,
                UGM                   = 3
            });

            fuels.Add(new FuelPricesViewModel
            {
                CurrencyName          = "test",
                Id                    = 1,
                DeliveryMaxValue      = 100,
                DeliveryMinValue      = 120,
                FuelPriceMaxBrutto    = 40,
                FuelPriceMinNetto     = 30,
                FormOfCooperationName = "b2b",
                FuelPriceMaxNetto     = 80,
                FuelPriceMinBrutto    = 70,
                DeliveryCombinedValue = "100 - 200",
                Rebate                = 30,
                UGM                   = 3
            });

            fuels.Add(new FuelPricesViewModel
            {
                CurrencyName          = "test",
                Id                    = 1,
                DeliveryMaxValue      = 100,
                DeliveryMinValue      = 120,
                FuelPriceMaxBrutto    = 40,
                FuelPriceMinNetto     = 30,
                FormOfCooperationName = "b2b",
                FuelPriceMaxNetto     = 80,
                FuelPriceMinBrutto    = 70,
                DeliveryCombinedValue = "100 - 200",
                Rebate                = 30,
                UGM                   = 3
            });

            fuels.Add(new FuelPricesViewModel
            {
                CurrencyName          = "tenmjk,kst",
                Id                    = 1,
                DeliveryMaxValue      = 100,
                DeliveryMinValue      = 120,
                FuelPriceMaxBrutto    = 40,
                FuelPriceMinNetto     = 30,
                FormOfCooperationName = "b2b",
                FuelPriceMaxNetto     = 80,
                FuelPriceMinBrutto    = 70,
                DeliveryCombinedValue = "100 - 200",
                Rebate                = 30,
                UGM                   = 3
            });

            fuels.Add(new FuelPricesViewModel
            {
                CurrencyName          = "tnmghfgest",
                Id                    = 4,
                DeliveryMaxValue      = 100,
                DeliveryMinValue      = 120,
                FuelPriceMaxBrutto    = 40,
                FuelPriceMinNetto     = 30,
                FormOfCooperationName = "b2b",
                FuelPriceMaxNetto     = 80,
                FuelPriceMinBrutto    = 70,
                DeliveryCombinedValue = "100 - 200",
                Rebate                = 30,
                UGM                   = 3
            });

            fuels.Add(new FuelPricesViewModel
            {
                CurrencyName          = "jghmghm",
                Id                    = 3,
                DeliveryMaxValue      = 100,
                DeliveryMinValue      = 120,
                FuelPriceMaxBrutto    = 40,
                FuelPriceMinNetto     = 30,
                FormOfCooperationName = "b2c",
                FuelPriceMaxNetto     = 80,
                FuelPriceMinBrutto    = 70,
                DeliveryCombinedValue = "101- 200",
                Rebate                = 30,
                UGM                   = 3
            });

            fuels.Add(new FuelPricesViewModel
            {
                CurrencyName          = "dfsdfsd",
                Id                    = 2,
                DeliveryMaxValue      = 34,
                DeliveryMinValue      = 50,
                FuelPriceMaxBrutto    = 55,
                FuelPriceMinNetto     = 30,
                FormOfCooperationName = "b2c",
                FuelPriceMaxNetto     = 80,
                FuelPriceMinBrutto    = 70,
                DeliveryCombinedValue = "100 - 203",
                Rebate                = 30,
                UGM                   = 3
            });

            var result = fuels.AsEnumerable();

            return(View(result));
        }
示例#6
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;
            }
        }
        //public void Handle(NewQuotationCommand message)
        //{
        //    foreach (var element in message.QuotationViewModels)
        //    {
        //        SaveFuelPriceData(element);
        //    }
        //}

        private void SaveFuelPriceData(FuelPricesViewModel fuelPriceDataToSave)
        {
            var priceList = _fuelPriceService.AddNewPriceList(fuelPriceDataToSave);

            priceList.Save();
        }