Пример #1
0
        /// <summary>
        /// This is used by the block forecast partial view.  It shows the actuals for this block over time.
        /// </summary>
        /// <param name="results"></param>
        /// <returns></returns>
        public static PreviousBlockActualViewModel ToViewModel(this IQueryable <fn_GetPreviousHarvestActualsResult> results)
        {
            if (results == null)
            {
                return(new PreviousBlockActualViewModel());
            }
            else
            {
                //Build new model.
                PreviousBlockActualViewModel model = new PreviousBlockActualViewModel();
                model.previousBlockActuals = results
                                             .OrderBy(x => x.HarvestDate)
                                             .Select(x => new PreviousBlockActual
                {
                    cropYear    = x.CropYear,
                    harvestDate = x.HarvestDate,
                    blockId     = x.BlockID,
                    bins        = x.Bins
                }).ToList();

                return(model);
            }
        }
        /// <summary>
        /// This partial class shows up in the Block Forecast view.  It displays actual harvest results over time.
        /// </summary>
        /// <param name="blockId"></param>
        /// <returns></returns>
        public ActionResult _PreviousBlockActuals(string blockId)
        {
            PreviousBlockActualViewModel model = Repository.GetPreviousHarvestActualResult(blockId).ToViewModel();

            return(PartialView(model));
        }