コード例 #1
0
        private List <VisitPlanModel> PrepareSummaryView(VisitPlanModel plan, string operationNumber, int year)
        {
            var availableYears = new List <int> {
                DateTime.Today.Year, DateTime.Today.Year + 1
            };

            var visitPlans = VisitRepository.GetByOperationAndYear(operationNumber, availableYears);

            if (plan != null)
            {
                visitPlans.Add(plan);
            }

            visitPlans.Sort((s1, s2) => s1.Year.CompareTo(s2.Year));

            if (visitPlans.All(s => s.Year != year))
            {
                year = availableYears.First();
            }

            foreach (var v in visitPlans)
            {
                v.ActualVersionEditable            = true;
                v.ActualVersionIsApproved          = false;
                v.ActualVersionCanModify           = false;
                v.ActualVersionIsInDraftOrModified = true;
                v.ActualVersionIsInModified        = true;
            }

            SetLocalizedValues();

            ViewBag.OperationNumber = operationNumber;
            ViewBag.AvailableYears  = availableYears;

            ViewBag.SelectedYear = year;
            var ModelOperation = _clientBasicData.OperationGet(operationNumber);

            ViewBag.OperationId = ModelOperation.OperationId;
            ViewBag.VisitPlan   = visitPlans;
            return(visitPlans);
        }