Exemplo n.º 1
0
        public IHttpActionResult Get(Int32 eventID)
        {
            SeatingListViewModel viewmodel     = new SeatingListViewModel();
            SeatDataController   dataCtrl      = new SeatDataController();
            EventDataController  eventDataCtrl = new EventDataController();

            if (!eventDataCtrl.GetItem(eventID).IsActiveReservation)
            {
                return(Warning(viewmodel, "Die Reservierung ist derzeit deaktiviert."));
            }

            var seats = dataCtrl.GetItems().Where(x => x.EventID == eventID).ToList();

            for (int i = 1; i <= Properties.Settings.Default.SeatAmount; i++)
            {
                SeatingViewModelItem item = new SeatingViewModelItem();
                Seat model = seats.FirstOrDefault(x => x.SeatNumber == i);
                if (model == null)
                {
                    model = new Seat()
                    {
                        SeatNumber = i,
                        State      = 0
                    }
                }
                ;
                item.FromModel(model);
                viewmodel.Data.Add(item);
            }

            return(Ok(viewmodel));
        }
Exemplo n.º 2
0
        public static AccountReservationEventViewModelItem FromModel(this AccountReservationEventViewModelItem viewmodel, Event model, User user)
        {
            SeatDataController seatDataCtrl = new SeatDataController();

            viewmodel.ID    = model.ID;
            viewmodel.Name  = model.EventType.Name + " Vol." + model.Volume;
            viewmodel.Seats = seatDataCtrl.GetItems().Where(x => x.EventID == model.ID && x.UserID == user.ID).ToList().ConvertAll(x => {
                var vm = new AccountReservationSeatViewModelItem();
                vm.FromModel(x);
                return(vm);
            });
            viewmodel.TransferedSeats = seatDataCtrl.GetItems().Where(x => x.EventID == model.ID && x.TransferUserID == user.ID).ToList().ConvertAll(x => {
                var vm = new AccountReservationTransferedSeatViewModelItem();
                vm.FromModel(x);
                return(vm);
            });

            return(viewmodel);
        }
Exemplo n.º 3
0
        public IHttpActionResult Backend_Get()
        {
            BackendSeatingListViewModel viewmodel     = new BackendSeatingListViewModel();
            SeatDataController          dataCtrl      = new SeatDataController();
            EventDataController         eventDataCtrl = new EventDataController();
            UserDataController          userDataCtrl  = new UserDataController();

            var events = eventDataCtrl.GetItems().OrderByDescending(x => x.Start).ToList();
            var users  = userDataCtrl.GetItems().OrderBy(x => x.FirstName).ToList();
            var eID    = events[0].ID;
            var seats  = dataCtrl.GetItems().Where(x => x.EventID == eID).ToList();

            viewmodel.Filter.EventOptions = events.ConvertAll(x =>
            {
                return(new SeatingFilterEvent()
                {
                    ID = x.ID,
                    Name = $"{x.EventType.Name} Vol.{x.Volume}"
                });
            });
            viewmodel.Filter.EventSelected = viewmodel.Filter.EventOptions[0];

            for (int i = 1; i <= Properties.Settings.Default.SeatAmount; i++)
            {
                BackendSeatingViewModelItem item = new BackendSeatingViewModelItem();
                Seat model = seats.FirstOrDefault(x => x.SeatNumber == i);
                if (model == null)
                {
                    model = new Seat()
                    {
                        SeatNumber = i,
                        State      = 0,
                        Event      = events[0]
                    }
                }
                ;
                item.FromModel(model);
                viewmodel.Data.Add(item);
            }

            return(Ok(viewmodel));
        }
Exemplo n.º 4
0
        public IHttpActionResult Backend_Detail_Update(Int32 EventID, Int32 SeatNumber, BackendSeatingViewModelItem request)
        {
            BackendSeatingViewModel viewmodel = new BackendSeatingViewModel();
            SeatDataController      dataCtrl  = new SeatDataController();

            try
            {
                var  seats  = dataCtrl.GetItems().Where(x => x.EventID == EventID);
                Seat model  = seats.FirstOrDefault(x => x.SeatNumber == SeatNumber);
                Seat result = null;
                if (request.ReservationState.Key != 0)
                {
                    if (model == null)
                    {
                        result = dataCtrl.Insert(request.ToModel());
                    }
                    else
                    {
                        result    = request.ToModel();
                        result.ID = model.ID;
                        result    = dataCtrl.Update(result);
                    }
                    viewmodel.Data.FromModel(result);
                }
                else
                {
                    if (model != null)
                    {
                        dataCtrl.Delete(model.ID);
                    }
                }
            }
            catch (Exception ex)
            {
                return(Error(viewmodel, ex));
            }

            return(Ok(viewmodel, "Sitzplatz gespeichert."));
        }
Exemplo n.º 5
0
        public IHttpActionResult Backend_Detail(Int32 EventID, Int32 SeatNumber)
        {
            BackendSeatingViewModel viewmodel     = new BackendSeatingViewModel();
            SeatDataController      dataCtrl      = new SeatDataController();
            EventDataController     eventDataCtrl = new EventDataController();
            UserDataController      userDataCtrl  = new UserDataController();

            try
            {
                viewmodel.UserOptions = userDataCtrl.GetItems().OrderBy(x => x.FirstName).ToList().ConvertAll(x =>
                {
                    return(new BackendUserViewModelItem().FromModel(x));
                });

                var  seats = dataCtrl.GetItems().Where(x => x.EventID == EventID);
                Seat model = seats.FirstOrDefault(x => x.SeatNumber == SeatNumber);
                if (model == null)
                {
                    model = new Seat()
                    {
                        SeatNumber      = SeatNumber,
                        State           = 0,
                        Event           = eventDataCtrl.GetItem(EventID),
                        ReservationDate = DateTime.Now
                    }
                }
                ;
                viewmodel.Data.FromModel(model);
            }
            catch (Exception ex)
            {
                return(Error(viewmodel, ex));
            }

            return(Ok(viewmodel));
        }
        public IHttpActionResult Frontend()
        {
            NavigationViewModel viewmodel    = new NavigationViewModel();
            EventDataController dataCtrl     = new EventDataController();
            SeatDataController  seatDataCtrl = new SeatDataController();
            PartnerDisplayRelationDataController displayDataCtrl = new PartnerDisplayRelationDataController();
            var events    = dataCtrl.GetItems().ToList();
            var nextEvent = events.OrderByDescending(x => x.Start).First();

            if (events.OrderByDescending(x => x.Start).FirstOrDefault(x => x.End > DateTime.Now) != null)
            {
                nextEvent = events.OrderByDescending(x => x.Start).FirstOrDefault(x => x.End > DateTime.Now);
            }
            var partner = displayDataCtrl.GetItems()
                          .Where(x => x.Partner.IsActive)
                          .OrderByDescending(x => x.Partner.PartnerPackID)
                          .ThenBy(x => x.Partner.Position);

            #region NavigationTop
            viewmodel.Data.NavigationTop.Add(new NavItem()
            {
                Text         = "News",
                State        = "news.all",
                StateCompare = "news"
            });
            viewmodel.Data.NavigationTop.Add(new NavItem()
            {
                Text         = "Events",
                State        = "event.all",
                StateCompare = "event"
            });
            viewmodel.Data.NavigationTop.Add(new NavItem()
            {
                Text         = "Galerie",
                State        = "gallery.all",
                StateCompare = "gallery"
            });
            viewmodel.Data.NavigationTop.Add(new NavItem()
            {
                Text         = "Turniere",
                State        = "event.tournaments.all({id: " + nextEvent.ID + "})",
                StateCompare = "event.tournaments"
            });
            viewmodel.Data.NavigationTop.Add(new NavItem()
            {
                Text         = "Sitzplan",
                State        = "event.seating({id: " + nextEvent.ID + "})",
                StateCompare = "event.seating"
            });
            viewmodel.Data.NavigationTop.Add(new NavItem()
            {
                Text         = "Sponsoren",
                State        = "partner",
                StateCompare = "partner"
            });
            #endregion
            #region NavigationUser
            if (UserHelper.Authenticated)
            {
                if (UserHelper.CurrentUserRole == UserRole.Admin || UserHelper.CurrentUserRole == UserRole.Team)
                {
                    viewmodel.Data.NavigationUser.Add(new NavItem()
                    {
                        Text         = "<i class='fas fa-user-secret'></i>",
                        State        = "admin.dashboard",
                        StateCompare = "admin.dashboard",
                        Tooltip      = "Adminbereich"
                    });
                }
                viewmodel.Data.NavigationUser.Add(new NavItem()
                {
                    Text         = "<i class='fas fa-utensils'></i>",
                    State        = "catering",
                    StateCompare = "catering",
                    Tooltip      = "Catering"
                });
                //viewmodel.Data.NavigationUser.Add(new NavItem()
                //{
                //    Text = "<i class='fas fa-comments'></i>",
                //    State = "profile.overview",
                //    StateCompare = "profile",
                //    Tooltip = "Chat"
                //});
                viewmodel.Data.NavigationUser.Add(new NavItem()
                {
                    Text         = "<i class='fas fa-user-circle'></i>",
                    State        = "profile.overview",
                    StateCompare = "profile",
                    Tooltip      = UserHelper.CurrentUserName
                });
                viewmodel.Data.NavigationUser.Add(new NavItem()
                {
                    Text         = "<i class='fas fa-sign-out'></>",
                    State        = "logout",
                    StateCompare = "logout",
                    Tooltip      = "Ausloggen"
                });
            }
            else
            {
                viewmodel.Data.NavigationUser.Add(new NavItem()
                {
                    Text         = "<i class='fas fa-user-plus'></i>",
                    State        = "register",
                    StateCompare = "register",
                    Tooltip      = "Registrieren"
                });
                viewmodel.Data.NavigationUser.Add(new NavItem()
                {
                    Text         = "<i class='fas fa-sign-in'></i>",
                    State        = "login",
                    StateCompare = "login",
                    Tooltip      = "Einloggen"
                });
            }
            #endregion
            #region NavigationAside
            viewmodel.Data.NavigationAside.Add(new NavItem()
            {
                Text  = "Informationen",
                State = "event.details({id: " + nextEvent.ID + "})"
            });
            viewmodel.Data.NavigationAside.Add(new NavItem()
            {
                Text  = "Sitzplan",
                State = "event.seating({id: " + nextEvent.ID + "})"
            });
            viewmodel.Data.NavigationAside.Add(new NavItem()
            {
                Text  = "Jugendschutz",
                State = "jugendschutz"
            });
            viewmodel.Data.NavigationAside.Add(new NavItem()
            {
                Text  = "Teilnahmebedingungen",
                State = "teilnahmebedingungen"
            });
            viewmodel.Data.NavigationAside.Add(new NavItem()
            {
                Text  = "Kontakt",
                State = "contact"
            });
            #endregion
            #region EventsAside
            foreach (var e in events.Where(x => x.End > DateTime.Now).OrderByDescending(x => x.Start))
            {
                var   seats      = seatDataCtrl.GetItems().Where(x => x.EventID == e.ID);
                Int32 seatsCount = Properties.Settings.Default.SeatAmount - seats.Count(x => x.State == -1);
                Int32 flagged    = seats.Count(x => x.State == 1);
                Int32 reserved   = seats.Count(x => x.State >= 2);
                Int32 free       = seatsCount - flagged - reserved;
                viewmodel.Data.EventsAside.Add(new EventItem()
                {
                    ID           = e.ID,
                    Title        = $"{e.EventType.Name} Vol.{e.Volume}",
                    Start        = e.Start,
                    End          = e.End,
                    PublicAccess = !e.IsPrivate,
                    Seating      = new data.ViewModel.Event.EventViewModelItem.SeatingReservation()
                    {
                        SeatsCount = seatsCount,
                        Flagged    = flagged,
                        Reserved   = reserved,
                        Free       = free
                    }
                });
            }
            #endregion
            #region PartnerTop
            foreach (var p in partner.Where(x => x.PartnerDisplay.Name == "Header"))
            {
                viewmodel.Data.PartnerTop.Add(new PartnerItem()
                {
                    Name          = p.Partner.Name,
                    Link          = p.Partner.Link,
                    ImagePassive  = Properties.Settings.Default.imageAbsolutePath + p.Partner.ImagePassive,
                    ImageOriginal = Properties.Settings.Default.imageAbsolutePath + p.Partner.ImageOriginal
                });
            }
            #endregion
            #region NavigationBottom
            foreach (var p in partner.Where(x => x.PartnerDisplay.Name == "Footer"))
            {
                viewmodel.Data.NavigationBottom.Add(new LinkItem()
                {
                    Text = p.Partner.Name,
                    Link = p.Partner.Link
                });
            }
            #endregion

            return(Ok(viewmodel));
        }