Пример #1
0
        public async Task <string> RenderAnalysis()
        {
            ReportAnalysisViewModel rvm = new ReportAnalysisViewModel();

            rvm.nitratePresent = false;

            rvm.details = new List <ReportAnalysisDetail>();

            List <FarmManure> manures = _ud.GetFarmManures();

            foreach (var m in manures)
            {
                ReportAnalysisDetail rd = new ReportAnalysisDetail();

                rd.manureName  = m.name;
                rd.moisture    = m.moisture.ToString();
                rd.ammonia     = m.ammonia.ToString("#0");
                rd.nitrogen    = m.nitrogen.ToString("#0.00");
                rd.phosphorous = m.phosphorous.ToString("#0.00");
                rd.potassium   = m.potassium.ToString("#0.00");
                rd.nitrate     = m.nitrate.HasValue ? m.nitrate.Value.ToString("#0"): "n/a";

                if (m.nitrate.HasValue)
                {
                    rvm.nitratePresent = true;
                }
                rvm.details.Add(rd);
            }

            var result = await _viewRenderService.RenderToStringAsync("~/Views/Report/ReportAnalysis.cshtml", rvm);

            return(result);
        }
 public ReportAnalysisControl()
 {
     InitializeComponent();
     vm      = DataContext as ReportAnalysisViewModel;
     Loaded += ReportAnalysisControl_Loaded;
 }