private static void SetResLiquidOxides(
           IXLWorksheet ws,
           OxidesByTemperatureModel model,
           int currentRow,
           int currentColumn)
        {
            currentRow = currentRow + Model.OxidesResultModel.Count + 9;
            ws.Cell(currentRow, currentColumn - 1).Value = model.Temperature;
            float sum = 0;
            foreach (var oxide in model.OxidesResult)
            {
                sum += oxide.Percentage;
                ws.Cell(currentRow, currentColumn).Value = oxide.Percentage;

                currentColumn++;
            }

            ws.Cell(currentRow, currentColumn).Value = model.OxidesResult.Sum(x => x.Percentage);
        }
 private static void SetSolidPhaseOxide(
     IXLWorksheet ws,
     OxidesByTemperatureModel model,
     int currentRow,
     ref int currentColumn)
 {
     foreach (var oxide in model.OxidesResult)
     {
         ws.Cell(currentRow, currentColumn).Value = oxide.Percentage;
         currentColumn++;
     }
 }
 private static void SetOriginalOxides(
     IXLWorksheet ws,
     OxidesByTemperatureModel model,
     int currentRow,
     ref int currentColumn)
 {
     foreach (var oxide in model.OxidesResult)
     {
         ws.Cell(currentRow, currentColumn).Value =
             Model.Oxides.First(x => x.Composition.Formula == oxide.Oxide.Formula).Percentage;
         currentColumn++;
     }
 }
        private static void SetLiquidOxides(
           IXLWorksheet ws,
           OxidesByTemperatureModel model,
           int currentRow,
           int currentColumn)
        {
            float sum = 0;
            foreach (var oxide in model.OxidesResult)
            {
                sum += oxide.Percentage;
                ws.Cell(currentRow, currentColumn).Value = oxide.Percentage;

                currentColumn++;
            }
            ws.Cell(currentRow, currentColumn).Value = sum;
        }
        private void SetOxidesResult()
        {
            var oxides = new List<Oxide>(this.Oxides.Where(x => x.Composition.IsRequred).Select(x => x.Composition));
            oxides.Add(this.firstOxide);
            oxides.Add(this.secondOxide);

            foreach (var model in this.resTemperaturesModels)
            {
                var oxideResult = new OxidesByTemperatureModel();
                oxideResult.Temperature = model.Temperature;
                foreach (var oxide in oxides)
                {
                    float sum = 0;
                    foreach (var phase in model.FirstSystem.Phases)
                    {
                        var curOxide = phase.Phase.Oxides.FirstOrDefault(x => x.Oxide.Formula == oxide.Formula);
                        if (curOxide != null)
                        {
                            sum += (phase.Percentage*curOxide.Percentage)/100;
                        }
                    }
                    foreach (var phase in model.SecondSystem.Phases)
                    {
                        var curOxide = phase.Phase.Oxides.FirstOrDefault(x => x.Oxide.Formula == oxide.Formula);
                        if (curOxide != null)
                        {
                            sum += (phase.Percentage * curOxide.Percentage) / 100;
                        }
                    }
                    oxideResult.OxidesResult.Add(new OxideResultModel()
                    {
                        Oxide = oxide,
                        Percentage = sum
                    });
                }
                model.SetSolidSum();
                this.oxidesResultModels.Add(oxideResult);
            }

            this.SaveExcelResult();
        }
        private void SetMeltsOxidesRes()
        {
            this.OxidesInMeltRes = new List<OxidesByTemperatureModel>();
            foreach (var oxide in this.OxidesInMelt)
            {
                var model = new OxidesByTemperatureModel();
                model.Temperature = oxide.Temperature;
                var sum = oxide.OxidesResult.Sum(x => x.Percentage);
                foreach (var resultModel in oxide.OxidesResult)
                {
                    var resModelOxide = new OxideResultModel()
                                            {
                                                Oxide = resultModel.Oxide,
                                                Percentage = (resultModel.Percentage * 100) / sum
                                            };
                    model.OxidesResult.Add(resModelOxide);
                }

                this.SetFullPercentage(model.OxidesResult);

                this.OxidesInMeltRes.Add(model);
            }
        }
        public void SetMeltsOxides()
        {
            this.OxidesInMelt = new List<OxidesByTemperatureModel>();
            foreach (var oxide in this.OxidesResultModel)
            {
                var model = new OxidesByTemperatureModel();
                model.Temperature = oxide.Temperature;
                foreach (var res in oxide.OxidesResult)
                {
                    model.OxidesResult.Add(new OxideResultModel()
                                               {
                                                   Oxide = res.Oxide,
                                                   Percentage = this.Oxides.First(x => x.Composition.Formula == res.Oxide.Formula).Percentage - res.Percentage
                                               });
                }
                var mainOxides = this.OxidesResultModel.First().OxidesResult.Select(x => x.Oxide.Formula);
                foreach (var origOxide in this.Oxides.Where(x => !mainOxides.Contains(x.Composition.Formula)))
                {
                    model.OxidesResult.Add(new OxideResultModel()
                    {
                        Oxide = origOxide.Composition,
                        Percentage = origOxide.Percentage
                    });
                }
                this.OxidesInMelt.Add(model);
            }

            this.SetMeltsOxidesRes();
        }