Exemplo n.º 1
0
        public PhysicianEventQueueListModel Create(IEnumerable <PhysicianEventQueueListItem> eventQueueListItems, IEnumerable <OrderedPair <long, string> > physiciansIdNamePairs, IEnumerable <Event> events, IEnumerable <Pod> pods)
        {
            var model      = new PhysicianEventQueueListModel();
            var collection = new List <PhysicianEventQueueViewModel>();

            foreach (var item in eventQueueListItems)
            {
                var physicianName = physiciansIdNamePairs.Where(p => p.FirstValue == item.PhysicianId).First().SecondValue;
                var eventData     = events.Where(e => e.Id == item.EventId).First();
                var eventPods     = pods.Where(p => eventData.PodIds.Contains(p.Id));
                var podName       = !eventPods.IsNullOrEmpty() ? string.Join(", ", eventPods.Select(pod => pod.Name)) : string.Empty;

                collection.Add(new PhysicianEventQueueViewModel()
                {
                    PhysicianName    = physicianName,
                    EventId          = eventData.Id,
                    EventDate        = eventData.EventDate,
                    EventName        = eventData.Name,
                    Vehicle          = podName,
                    CustomersInQueue = item.CustomersInQueue,
                    PhysicianId      = item.PhysicianId
                });
            }

            model.Collection = collection;
            return(model);
        }
Exemplo n.º 2
0
        public ActionResult PhysicianEventQueue(PhysicianEventQueueListModelFilter filter = null, int pageNumber = 1)
        {
            var filterValidator = IoC.Resolve <PhysicianEventQueueListModelFilterValidator>();
            var result          = filterValidator.Validate(filter);

            if (result.IsValid)
            {
                int totalRecords = 0;

                var model = _physicianEvaluationService.GetPhysicianEventQueue(pageNumber, _pageSize, filter, out totalRecords);

                if (model == null)
                {
                    model = new PhysicianEventQueueListModel();
                }

                model.Filter = filter;

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

                Func <int, string> urlFunc =
                    pn => Url.Action(currentAction, new
                {
                    pageNumber = pn,
                    filter.EventId,
                    filter.FromDate,
                    filter.ToDate,
                    filter.DateType,
                    filter.PhysicianId,
                    filter.PodId,
                    filter.RecordsforPrimaryEval,
                    filter.IsRetailEvent,
                    filter.IsCorporateEvent,
                    filter.IsPublicEvent,
                    filter.IsPrivateEvent
                });

                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 PhysicianEventQueueListModel {
                Filter = filter, FeedbackMessage = FeedbackMessageModel.CreateFailureMessage(htmlString)
            }));
        }