Beispiel #1
0
        // GET: Events
        public ActionResult Index()
        {
            List <EventViewModel> listOfEvents = _eventRepo.GetAllEvents().ToList();

            ViewBag.Categories = GetCategories();
            return(View(listOfEvents));
        }
        internal EventsIndexVM[] GetAllEventFromDB()
        {
            Events[]        events = eventsRepository.GetAllEvents();
            EventsIndexVM[] ie     = new EventsIndexVM[events.Length];

            for (int i = 0; i < ie.Length; i++)
            {
                ie[i] = new EventsIndexVM
                {
                    Date      = events[i].Date,
                    EventType = ConvertEventTypeToString(events[i].EventType),
                    Id        = events[i].Id,
                };

                if (events[i].Customer != null)
                {
                    ie[i].CustomerFirstName = events[i].Customer.FirstName;
                    ie[i].CustomerLastName  = events[i].Customer.LastName;
                    ie[i].CustomerId        = events[i].CustomerId;
                }
                ;

                if (events[i].Car != null)
                {
                    ie[i].CarRegNr = events[i].Car.Registrationnumber;
                    ie[i].CarId    = events[i].CarId;
                }
            }

            return(ie);
        }
Beispiel #3
0
 public IActionResult GetEvents([FromHeader(Name = "id_token")] string googleToken)
 {
     try
     {
         if (googleAuth.ProcessRequestAtGoogle(googleToken))
         {
             var allEvents = eventsRepository.GetAllEvents();
             return(Ok(allEvents));
         }
         else
         {
             return(BadRequest());
         }
     }
     catch (Exception exp)
     {
         return(NotFound());
     }
 }
        public async Task <ActionResult <int> > CreateEvent(EventDto newEvent)
        {
            var currUser = await _userRepository.GetUserByUsernameAsync(User.GetUsername());

            var events = await _eventsRepository.GetAllEvents();

            var matchingDates = events.Where(e => e.Date == newEvent.Date);

            var matchingEvents = matchingDates.Where(e => e.Name == newEvent.Name);

            if (matchingEvents.Count() > 0)
            {
                return(BadRequest("Event already exists!"));
            }

            var createdEvent = new Event
            {
                Name      = newEvent.Name,
                Date      = newEvent.Date,
                Location  = newEvent.Location,
                Creator   = currUser,
                CreatorId = currUser.Id
            };

            var userEvent = new UserEvents
            {
                OrganiserId = currUser.Id,
                EventId     = createdEvent.Id
            };

            createdEvent.Organisers = new List <UserEvents>();

            createdEvent.Organisers.Add(userEvent);

            return(await _eventsRepository.CreateEvent(createdEvent));
        }
Beispiel #5
0
 private Task <List <EventInfo> > GetEventInfos(EventsCommand command)
 {
     return(command.OneDay ? _repository.GetEvents(command.DayOfWeek) : _repository.GetAllEvents());
 }
Beispiel #6
0
        public async void GetAllEventsTest()
        {
            var result = await _eventsRepository.GetAllEvents();

            Assert.True(result.ToList().Count() > 0);
        }
 public IEnumerable <Event> GetAllEvents(bool fullyHydrate = true)
 {
     return(_EventsRepository.GetAllEvents(fullyHydrate));
 }
 public async Task <IEnumerable <Events> > GetAllEvents()
 {
     return(await _eventsRepository.GetAllEvents());
 }
Beispiel #9
0
 public Task <IEnumerable <Event> > Get()
 {
     return(_eventsRepository.GetAllEvents());
 }
Beispiel #10
0
        public IActionResult EventIndex()
        {
            var allEvents = _eventsRepository.GetAllEvents();

            return(View(allEvents));
        }