예제 #1
0
        public ActionResult UpdateSystemSettings(SystemSettings systemSettings)
        {
            try
            {
                if (systemSettings != null && !string.IsNullOrEmpty(systemSettings.demand))
                {
                    systemSettings.demand = systemSettings.demand.Replace(",", "");
                }

                if (this.Session["IsNewCustomer"].ToString() == "True")
                {
                    this.modifiedCondRepository.AddSystemSettings(systemSettings, this.Session["CustomerId"].ToString());
                    this.Session["HasTrainDetails"] = "No";
                    return RedirectToAction("DashBoard");
                }
                else
                {
                    this.modifiedCondRepository.UpdateSystemSettings(systemSettings, this.Session["CustomerId"].ToString());
                    this.Session["HasTrainDetails"] = "Verify";
                    return RedirectToAction("DashBoard");
                }
            }
            catch
            {
                throw;
            }
        }
예제 #2
0
        public ActionResult GetSystemSettings()
        {
            SystemSettings settings = new SystemSettings();
            try
            {
                string customerId = this.Session["CustomerId"].ToString();
                customer customer = this.modifiedCustRepository.FindById(customerId);
                var train = this.trainRepository.GetAll().Where(p => p.customer_customerID == customer.customerID).FirstOrDefault();
                if (train != null)
                {
                    if (train.using_manifold.Equals("NO"))
                    {
                        settings.isManifold = false;
                    }
                    else
                    {
                        settings.isManifold = true;
                    }
                    this.Session["IsNewCustomer"] = "False";
                }
                else
                {
                    this.Session["IsNewCustomer"] = "True";
                }
                settings.acid_price = customer.acid_price;
                settings.caustic_price = customer.caustic_price;
                settings.demand = Convert.ToString(customer.demand);
                var sources = this.sourceRepository.GetAll().OrderBy(item => item.full_site_name);
                foreach (var item in sources)
                {
                    if (item.state_name == customer.state && item.city == customer.city)
                    {
                        settings.WaterSourceList1.Add(new SelectListItem() { Text = item.full_site_name, Value = Convert.ToString(item.sources_sourceID) });
                    }
                }
                foreach (var item in sources)
                {
                    if (item.state_name == customer.state && item.city == customer.city)
                    {
                        settings.WaterSourceList2.Add(new SelectListItem() { Text = item.full_site_name, Value = Convert.ToString(item.sources_sourceID) });
                    }
                }
                var allCustWaters = this.modifiedCustWaterRepository.GetAll();
                var custWaters = allCustWaters.Where(p => p.customer_customerID == customer.customerID).FirstOrDefault();
                source firstWaterSource = null;
                source secondWaterSource = null;

                if (custWaters != null)
                {
                    if (custWaters.first_sourceID != 0)
                    {
                        firstWaterSource = sources.Where(p => p.sources_sourceID == custWaters.first_sourceID && p.state_name == customer.state).FirstOrDefault();
                        if (firstWaterSource != null)
                        {
                            settings.firstWaterSource = Convert.ToString(firstWaterSource.sources_sourceID);
                        }
                        else
                        {
                            settings.firstWaterSource = string.Empty;
                        }
                    }
                    if (custWaters.second_sourceID != 0)
                    {
                        secondWaterSource = sources.Where(p => p.sources_sourceID == custWaters.second_sourceID && p.state_name == customer.state).FirstOrDefault();
                        if (secondWaterSource != null)
                        {
                            settings.secondWaterSource = Convert.ToString(secondWaterSource.sources_sourceID);
                        }
                        else
                        {
                            settings.secondWaterSource = string.Empty;
                        }
                    }
                    settings.firstWSPercentage = custWaters.firstSourcePercentage;
                }
                if (firstWaterSource != null && secondWaterSource != null)
                {
                    settings.HasTwoSources = true;
                }
            }
            catch
            {
                throw;
            }
            return this.PartialView("_SystemSettings", settings);
        }