Ejemplo n.º 1
0
        public virtual ActionResult Save1(int versionPlanId, VisitPlanModel planModel, string operationNumber)
        {
            // Set default notification message
            var messageStatus = MessageNotificationCodes.SaveDataSucessfully;

            // Get duplicated visit types count
            var duplicatedVisitTypes = planModel.Visits.GroupBy(vt => vt.TypeVisitId).Where(vt => vt.Count() > 1).ToList();

            // Check if there is more than one visit of the same type
            if (duplicatedVisitTypes.Count() > 0)
            {
                messageStatus = MessageNotificationCodes.DuplicateVisitType;
            }
            else
            {
                VisitRepository.SaveVisit(versionPlanId, planModel);
            }

            return(RedirectToAction("VisitsPlanSummary", new
            {
                operationNumber = operationNumber,
                year = planModel.Year,
                messageStatus = messageStatus
            }));
        }
Ejemplo n.º 2
0
        public virtual ActionResult EditVisits(int visitPlanId)
        {
            ViewBag.EditMode = true;
            SetLocalizedValues();
            VisitPlanModel planModel = new VisitPlanModel()
            {
                VisitPlanId = visitPlanId,
                Visits      = VisitRepository.GetVisitModel(visitPlanId),
            };

            return(PartialView(planModel));
        }
Ejemplo n.º 3
0
        public virtual PartialViewResult IndexVisitsPartial(int id)
        {
            ViewBag.EditMode = true;
            SetLocalizedValues();
            VisitPlanModel planModel = new VisitPlanModel()
            {
                Visits      = VisitRepository.GetVisitModel(id),
                VisitPlanId = id,
            };

            return(PartialView(planModel));
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
        public virtual ActionResult Edit(string operationNumber, int year, VisitsPlanView view = VisitsPlanView.Visit, bool createNew = false)
        {
            if (TempData.ContainsKey("IndexDocumentRelationshipError"))
            {
                ViewBag.UploadFileError = ((Exception)TempData["IndexDocumentRelationshipError"]).Message;
            }

            ViewBag.EditMode        = true;
            ViewBag.EditableView    = view;
            ViewBag.operationNumber = operationNumber;
            var            visitsPlans = PrepareSummaryView(null, operationNumber, year);
            VisitPlanModel plan        = null;

            if (createNew)
            {
                plan = new VisitPlanModel
                {
                    Year            = year,
                    OperationNumber = operationNumber
                };
            }

            if (year == DateTime.Now.Year)
            {
                visitsPlans             = PrepareSummaryView(plan, operationNumber, year);
                ViewBag.OperationId     = visitsPlans.Find(p => p.Year == year).OperationId;
                ViewBag.OperationNumber = visitsPlans.Find(p => p.Year == year).OperationNumber;
            }
            else if (year == DateTime.Now.Year + 1)
            {
                year        = DateTime.Now.Year + 1;
                visitsPlans = PrepareSummaryView(plan, operationNumber, year);
            }

            return(View("VisitsPlanSummary", visitsPlans));
        }