Esempio n. 1
0
        public ActionResult PcpAppointment(PcpAppointmentListModelFilter filter = null, int pageNumber = 1)
        {
            var filterValidator = IoC.Resolve <PcpAppointmentListModelFilterValidator>();
            var result          = filterValidator.Validate(filter);

            if (result.IsValid)
            {
                int totalRecords;
                var model = _eventCustomerReportingService.GetPcpAppointment(pageNumber, _pageSize, filter, out totalRecords);
                model        = model ?? new PcpAppointmentListModel();
                model.Filter = filter;

                var currentAction        = ControllerContext.RouteData.Values["action"].ToString();
                var routeValueDictionary = GetRouteValueDictionaryForPcpAppointment(filter);

                Func <int, string> urlFunc = pn => Url.Action(currentAction, AddRouteValueDictionary(routeValueDictionary, pn));

                model.PagingModel = new PagingModel(pageNumber, _pageSize, totalRecords, urlFunc);

                return(View(model));
            }

            var propertyNames = result.Errors.Select(e => e.PropertyName).Distinct();
            var htmlString    = propertyNames.Aggregate("", (current, property) => current + (result.Errors.Where(e => e.PropertyName == property).FirstOrDefault().ErrorMessage + "<br />"));

            return(View(new PcpAppointmentListModel {
                Filter = filter, FeedbackMessage = FeedbackMessageModel.CreateFailureMessage(htmlString)
            }));
        }
Esempio n. 2
0
        private RouteValueDictionary GetRouteValueDictionaryForPcpAppointment(PcpAppointmentListModelFilter filter)
        {
            var routeValueDictionary = new RouteValueDictionary
            {
                { "FromDate", filter.FromDate },
                { "ToDate", filter.ToDate },
                { "Tag", filter.Tag },
            };

            if (!filter.CustomTags.IsNullOrEmpty())
            {
                var index = 0;
                foreach (var customtag in filter.CustomTags)
                {
                    routeValueDictionary.Add(string.Format("CustomTags[{0}]", index), customtag);
                    index++;
                }
            }

            return(routeValueDictionary);
        }