public IActionResult Index(double debil)
        {
            AddInputDBData();

            viewModel.CalculateResults();

            return(View("Result", viewModel));
        }
Esempio n. 2
0
        public IActionResult Index(List <InputDataModel> input, string selectedCocks, double L1, double L2, double S1, double S2, double Wgr)
        {
            db.Inputs.RemoveRange(db.Inputs);
            db.Results.RemoveRange(db.Results);

            IndexViewModel viewModel = new IndexViewModel(input);

            System.Reflection.PropertyInfo[] cockses = typeof(CocksModel).GetProperties();
            viewModel.selectedCocks = (Cocks)cockses.FirstOrDefault(x => x.Name == selectedCocks).GetValue(null);

            viewModel.L1  = L1;
            viewModel.L2  = L2;
            viewModel.S1  = S1;
            viewModel.S2  = S2;
            viewModel.Wgr = Wgr;

            SettingsModel settings = new SettingsModel()
            {
                L1 = L1, L2 = L2, S1 = S1, S2 = S2, Wgr = Wgr, SelectedCocks = selectedCocks
            };

            StreamWriter sw = new StreamWriter(@"jija.json");

            sw.Write(JsonConvert.SerializeObject(settings));
            sw.Close();


            viewModel.CalculateResults();

            db.Inputs.AddRange(input);
            db.Results.AddRange(viewModel.Results);

            db.SaveChanges();

            return(View("Result", viewModel));
        }