예제 #1
0
 /// <summary>
 /// Gets the settings for CostAnalyzer chart
 /// </summary>
 /// <param name="customerId">customer Identifier</param>
 /// <param name="selectedTrain">selected Train</param>
 /// <returns>Returns the cost settings</returns>
 public CostSettings GetCostSettings(string customerId, string selectedTrain)
 {
     CostSettings settings = new CostSettings();
     try
     {
         if (int.Parse(selectedTrain) == 0)
         {
             settings.SelectedTrain = "All Trains";
         }
         else
         {
             train train = modifiedTrainRepository.FindById(selectedTrain);
             settings.SelectedTrain = train.number.ToString();
         }
         customer customer = this.modifiedCustRepository.FindById(customerId);
         settings.AcidPrice = customer.acid_price;
         settings.CausticPrice = customer.caustic_price;
     }
     catch (Exception)
     {
         throw;
     }
     return settings;
 }
예제 #2
0
        /// <summary>
        /// Gets the settings for CostAnalyzer chart
        /// </summary>
        /// <param name="customerId">customer Identifier</param>
        /// <param name="selectedTrain">selected Train</param>
        /// <returns>Returns the cost settings</returns>
        public CostSettings GetCostSettings(string customerId, string selectedTrain)
        {
            CostSettings settings = new CostSettings();
            List<double> LstCationUsage = new List<double>();
            List<double> LstAnionUsage = new List<double>();
            try
            {
                List<vessel> vessels = this.vesselRepository
                                            .GetAll()
                                            .Where(p => p.vessel_customerID == customerId)
                                            .ToList();
                if (int.Parse(selectedTrain) == 0)
                {
                    var CationReplacement = vessels
                                     .Where(p => (p.vessel_number % 2 != 0)).ToList()
                                     .Average(x => Convert.ToDecimal(x.price_per_cuft));
                    var AnionReplacement = vessels
                                            .Where(p => (p.vessel_number % 2 == 0)).ToList()
                                            .Average(x => Convert.ToDecimal(x.price_per_cuft));
                    var CationUsage = vessels
                                     .Where(p => (p.vessel_number % 2 != 0)).ToList()
                                     .Average(x => Convert.ToDecimal(x.lbs_chemical));
                    var AnionUsage = vessels
                                            .Where(p => (p.vessel_number % 2 == 0)).ToList()
                                            .Average(x => Convert.ToDecimal(x.lbs_chemical));
                    var CationResin = vessels
                                     .Where(p => (p.vessel_number % 2 != 0)).ToList()
                                     .Sum(x => Convert.ToDecimal(x.size));
                    var AnionResin = vessels
                                            .Where(p => (p.vessel_number % 2 == 0)).ToList()
                                            .Sum(x => Convert.ToDecimal(x.size));
                    settings.CationReplacementCost = Convert.ToDouble(CationReplacement);
                    settings.AnionReplacementCost = Convert.ToDouble(AnionReplacement);
                    settings.CationResin = Convert.ToInt32(CationResin);
                    settings.AnionResin = Convert.ToInt32(AnionResin);
                    settings.CausticUsage = Convert.ToInt32(AnionUsage);
                    settings.AcidUsage = Convert.ToInt32(CationUsage);
                    settings.SelectedTrain = "All Trains";
                }
                else
                {
                    if (vessels.Count > 0)
                    {
                        var CationReplacement = vessels
                                         .Where(p => (p.vessel_number % 2 != 0) && p.train_trainID == Convert.ToInt32(selectedTrain))
                                         .ToList()
                                         .Average(x => Convert.ToDecimal(x.price_per_cuft));
                        var AnionReplacement = vessels
                                                .Where(p => (p.vessel_number % 2 == 0) && p.train_trainID == Convert.ToInt32(selectedTrain)).ToList()
                                                .Average(x => Convert.ToDecimal(x.price_per_cuft));
                        var CationUsage = vessels
                                         .Where(p => (p.vessel_number % 2 != 0) && p.train_trainID == Convert.ToInt32(selectedTrain)).ToList()
                                         .Average(x => Convert.ToDecimal(x.lbs_chemical));
                        var AnionUsage = vessels
                                                .Where(p => (p.vessel_number % 2 == 0) && p.train_trainID == Convert.ToInt32(selectedTrain)).ToList()
                                                .Average(x => Convert.ToDecimal(x.lbs_chemical));
                        var CationResin = vessels
                                         .Where(p => (p.vessel_number % 2 != 0) && p.train_trainID == Convert.ToInt32(selectedTrain)).ToList()
                                         .Sum(x => Convert.ToDecimal(x.size));
                        var AnionResin = vessels
                                                .Where(p => (p.vessel_number % 2 == 0) && p.train_trainID == Convert.ToInt32(selectedTrain)).ToList()
                                                .Sum(x => Convert.ToDecimal(x.size));
                        settings.CationReplacementCost = Convert.ToDouble(CationReplacement);
                        settings.AnionReplacementCost = Convert.ToDouble(AnionReplacement);
                        settings.CationResin = Convert.ToInt32(CationResin);
                        settings.AnionResin = Convert.ToInt32(AnionResin);
                        settings.CausticUsage = Convert.ToInt32(AnionUsage);
                        settings.AcidUsage = Convert.ToInt32(CationUsage);

                        train train = modifiedTrainRepository.FindById(selectedTrain);
                        settings.SelectedTrain = train.number.ToString();
                    }
                }
                customer customer = this.modifiedCustRepository.FindById(customerId);
                settings.AcidPrice = customer.acid_price;
                settings.CausticPrice = customer.caustic_price;
            }
            catch (Exception)
            {
                throw;
            }
            return settings;
        }