Пример #1
0
        public IActionResult All(int pageNumber = 1)
        {
            var viewModel = new AllEventsViewModel();

            viewModel.Events          = eventsService.GetAllEvents(pageNumber);
            viewModel.PageNumber      = pageNumber - 1;
            viewModel.TotalPagesCount = eventsService.GetTotalPagesCount();
            return(View(viewModel));
        }
        public IActionResult All()
        {
            var model = new AllEventsViewModel()
            {
                Events = this.dbContext.Events
            };

            return(View(model));
        }
Пример #3
0
        public IActionResult All()
        {
            AllEventsViewModel viewModel = new AllEventsViewModel
            {
                EventsComing   = this.eventsService.GetAllComing <EventViewModel>(),
                EventsFinished = this.eventsService.GetAllFinished <EventViewModel>(),
            };

            return(this.View(viewModel));
        }
        public async Task <IActionResult> My()
        {
            var user = await userManager.FindByNameAsync(User.Identity.Name);

            var eventsViewModel = new AllEventsViewModel
            {
                Events = mapper.Map <OrderModel[], IEnumerable <EventViewModel> >(this.orders.ByUserId(user.Id).ToArray())
            };

            return(View(eventsViewModel));
        }
        // GET: Events
        public async Task <IActionResult> AllEvents()
        {
            //return View(await _context.Events.ToListAsync());
            var allEvents = this._context.Events.Select(e => _mapper.Map <Event, EventViewModel>(e)).ToList();

            var model = new AllEventsViewModel
            {
                AllEvents = allEvents
            };

            return(View("~/Views/Events/AllEvents.cshtml", model));
        }
        public async Task <IActionResult> AllEvents()
        {
            var allEvents = this._context.Events
                            .Select(e => _mapper.Map <Event, EventViewModel>(e)).ToList();

            var model = new AllEventsViewModel
            {
                Events = allEvents
            };

            return(this.View(model));
        }
        public IActionResult All(string errorMessage, int page = 1)
        {
            var eventsViewModel = new AllEventsViewModel
            {
                Events       = mapper.Map <EventModel[], IEnumerable <EventViewModel> >(this.events.All(page, PageSize).ToArray()),
                TotalPages   = (int)Math.Ceiling(this.events.Count() / (double)PageSize),
                CurrentPage  = page,
                PageSize     = PageSize,
                ErrorMessage = errorMessage
            };

            return(View(eventsViewModel));
        }
        public IActionResult All()
        {
            var allEventsViewModel = new AllEventsViewModel
            {
                Events = this.dbContext.Events.Select(e => new EventSmallDto
                {
                    Name  = e.Name,
                    Place = e.Place,
                    Start = e.Start,
                    End   = e.End
                }).ToList()
            };

            return(View(allEventsViewModel));
        }
Пример #9
0
        public async Task <IActionResult> AllEvents(MyErrorViewModel myError, int?page)
        {
            if (this.User.IsInRole("Admin"))
            {
                var allEvents = this.eventService.GetAllEvents().ToList();

                var adminModel = new AllEventsViewModel
                {
                    AllEvents = allEvents
                };

                _logger.LogDebug((int)LoggingEvents.CONTROLLER_ACCESSED, "Show all events.");

                return(View("AllEventsAdmin", adminModel));
            }

            var user = await this.userManager.FindByNameAsync(this.User.Identity.Name);

            var events = this.eventService.GetAllEvents().Select(o => new OrderViewModel
            {
                Customer    = user,
                EventId     = o.Id.ToString(),
                Name        = o.Name,
                Start       = o.Start,
                End         = o.End,
                Tickets     = 0,
                TicketsLeft = o.TicketsLeft
            }).ToList();

            var nextPage        = page ?? 1;
            var recordsPerPage  = 3;
            var pagedViewModels = events.ToPagedList(nextPage, recordsPerPage);

            var model = new OrdersViewModel
            {
                Orders     = pagedViewModels,
                OrderError = myError.ErrorMessage
            };

            _logger.LogDebug((int)LoggingEvents.CONTROLLER_ACCESSED, "Show all events.");

            ViewData["CurrentPage"]    = page ?? 1;
            ViewData["RecordsPerPage"] = recordsPerPage;
            ViewData["MyErrorOcurred"] = myError.ErrorMessage;

            return(View(model));
        }
Пример #10
0
        public IActionResult BuyTicket(AllEventsViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(All());
            }
            var id           = model.BuyTicketInputModel.Id;
            var ticketsCount = model.BuyTicketInputModel.TicketsCount;

            var isBought = eventsService.CanBuyTickets(id, ticketsCount, User);

            if (!isBought)
            {
                return(BadRequest("You cant buy this much tickets."));
            }
            return(this.Redirect("/Events/MyEvents"));
        }
Пример #11
0
        private void Event_Click(object sender, RoutedEventArgs e)
        {
            AllEventsView allEventsView = new AllEventsView();
            var           vm            = new AllEventsViewModel
                                          (
                mainWindowViewModel.ProgramService,
                mainWindowViewModel.ProjectService,
                mainWindowViewModel.ProgramTypeService,
                mainWindowViewModel.BatteryService,
                mainWindowViewModel.TesterService,
                mainWindowViewModel.ChannelService,
                mainWindowViewModel.ChamberService,
                mainWindowViewModel.BatteryTypeService
                                          );

            allEventsView.DataContext = vm;// new AllEventsViewModel(/*EventService*/);
            allEventsView.ShowDialog();
        }
Пример #12
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     AllEventsModel = NavigationServices.CurrentViewModel as AllEventsViewModel;
     if (e.NavigationMode == NavigationMode.New && NavigationContext.QueryString.ContainsKey("id"))
     {
         string id = NavigationContext.QueryString["id"];
         if (!String.IsNullOrEmpty(id))
         {
             _isDeepLink    = true;
             AllEventsModel = new AllEventsViewModel();
             NavigationServices.CurrentViewModel = AllEventsModel;
             AllEventsModel.LoadItem(id);
         }
     }
     if (AllEventsModel != null)
     {
         AllEventsModel.ViewType = ViewTypes.Detail;
     }
     DataContext = AllEventsModel;
     base.OnNavigatedTo(e);
 }
Пример #13
0
        public async Task <IActionResult> Index(string sortOrder    = null,
                                                string searchString = null, int?page = null, string currentFilter = null)
        {
            ViewData["userRealName"] = await _profileRepository.GetObjectsList();

            ViewData["SortName"]       = string.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
            ViewData["SortID"]         = sortOrder == "id" ? "id_desc" : "id";
            ViewData["SortDate"]       = sortOrder == "date" ? "date_desc" : "date";
            ViewData["SortLocation"]   = sortOrder == "location" ? "location_desc" : "location";
            ViewData["SortOrganizer"]  = sortOrder == "organizer" ? "organizer_desc" : "organizer";
            _eventRepository.SortOrder = sortOrder != null && sortOrder.EndsWith("_desc")
                ? SortOrder.Descending
                : SortOrder.Ascending;
            _eventRepository.SortFunction = getSortFunction(sortOrder);
            if (searchString != null)
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }
            ViewData["CurrentFilter"]     = searchString;
            _eventRepository.SearchString = searchString;
            _eventRepository.PageIndex    = page ?? 1;

            AllEventsViewModel allevents = new AllEventsViewModel();

            allevents.AllEventViewModel = await _eventRepository.GetObjectsList();

            allevents.MyEventsViewModel = await _attendingRepository.GetUserEventsList(GetCurrentUserID());

            allevents.MyOrganizedEventsViewModel = await _eventRepository.GetOrganizerEventsList(GetCurrentUserID());

            return(View(allevents));
        }
Пример #14
0
        public async Task <List <AllEventsViewModel> > GetAllAsync(string UserId)
        {
            EdumanUser user = await this.context.Users.FirstOrDefaultAsync(u => u.Id == UserId);

            List <AllEventsViewModel> events = new List <AllEventsViewModel>();

            if (await userManager.IsInRoleAsync(user, "Teacher"))
            {
                var resultList = this.context.Events.Where(a => a.TeacherId == UserId).ToList();
                foreach (var currentEvent in resultList)
                {
                    AllEventsViewModel temp = new AllEventsViewModel
                    {
                        StudentUsername = this.context.Users
                                          .FirstOrDefault(u => u.Id == currentEvent.StudentId).UserName,
                        TeacherUsername = this.context.Users
                                          .FirstOrDefault(u => u.Id == currentEvent.TeacherId).UserName,
                        EventDate = currentEvent.EventDate,
                        Type      = currentEvent.Type,
                        Id        = currentEvent.Id
                    };
                    events.Add(temp);
                }
            }
            else if (await userManager.IsInRoleAsync(user, "Principal"))
            {
                var resultList = this.context.Events.Where(
                    e => this.context.Users
                    .FirstOrDefault(u => u.Id == e.StudentId).School == user.School).ToList();

                foreach (var currentEvent in resultList)
                {
                    AllEventsViewModel temp = new AllEventsViewModel
                    {
                        StudentUsername = this.context.Users
                                          .FirstOrDefault(u => u.Id == currentEvent.StudentId).UserName,
                        TeacherUsername = this.context.Users
                                          .FirstOrDefault(u => u.Id == currentEvent.TeacherId).UserName,
                        Id        = currentEvent.Id,
                        EventDate = currentEvent.EventDate,
                        Type      = currentEvent.Type
                    };
                    events.Add(temp);
                }
            }
            else if (await userManager.IsInRoleAsync(user, "Student"))
            {
                var resultList = this.context.Events.Where(e => e.StudentId == UserId).ToList();
                foreach (var currentEvent in resultList)
                {
                    AllEventsViewModel temp = new AllEventsViewModel
                    {
                        StudentUsername = this.context.Users
                                          .FirstOrDefault(u => u.Id == currentEvent.StudentId).UserName,
                        TeacherUsername = this.context.Users
                                          .FirstOrDefault(u => u.Id == currentEvent.TeacherId).UserName,
                        Id        = currentEvent.Id,
                        EventDate = currentEvent.EventDate,
                        Type      = currentEvent.Type
                    };
                    events.Add(temp);
                }
            }
            return(events);
        }