public IHttpActionResult Backend_Detail(Int32 id)
        {
            BackendEventViewModel   viewmodel         = new BackendEventViewModel();
            EventDataController     dataCtrl          = new EventDataController();
            EventTypeDataController eventTypeDataCtrl = new EventTypeDataController();

            try
            {
                viewmodel.EventTypeOptions = eventTypeDataCtrl.GetItems().ToList().ConvertAll(x =>
                {
                    return(new BackendEventTypeViewModelItem()
                    {
                        ID = x.ID, Name = x.Name
                    });
                }).OrderByDescending(x => x.ID).ToList();

                viewmodel.Data.FromModel(dataCtrl.GetItem(id));
            }
            catch (Exception ex)
            {
                return(Error(viewmodel, ex));
            }

            return(Ok(viewmodel));
        }
        public IHttpActionResult Detail(Int32 eventID, Int32 seatNumber)
        {
            SeatingViewModel    viewmodel     = new SeatingViewModel();
            SeatDataController  dataCtrl      = new SeatDataController();
            EventDataController eventDataCtrl = new EventDataController();

            try
            {
                if (!eventDataCtrl.GetItem(eventID).IsActiveReservation)
                {
                    return(Warning(viewmodel, "Die Reservierung ist derzeit deaktiviert."));
                }
                viewmodel.BankAccount.FromProperties();
                viewmodel.Data.FromModel(dataCtrl.GetItem(seatNumber, eventID));

                if (viewmodel.Data.ReservationState < 0)
                {
                    return(Info(viewmodel, "Dieser Platz ist gesperrt und kann nicht reserviert werden."));
                }
                else if (viewmodel.Data.ReservationState > 0)
                {
                    return(Warning(viewmodel, $"Dieser Platz wurde bereits von {viewmodel.Data.User.Nickname} reserviert."));
                }
            }
            catch (Exception ex)
            {
                return(Error(viewmodel, ex));
            }

            return(Ok(viewmodel));
        }
        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));
        }
        public IHttpActionResult GetImages(int id)
        {
            GalleryViewModel    viewmodel = new GalleryViewModel();
            EventDataController dataCtrl  = new EventDataController();

            var ev    = dataCtrl.GetItem(id);
            var items = GalleryDataController.GetItems(id);

            viewmodel.FromModel(ev, items);

            return(Ok(viewmodel));
        }
        public IHttpActionResult Detail(Int32 id)
        {
            EventViewModel      viewmodel = new EventViewModel();
            EventDataController dataCtrl  = new EventDataController();

            try
            {
                viewmodel.Data = new EventViewModelItem().FromModel(dataCtrl.GetItem(id));
            }
            catch (Exception ex)
            {
                return(Error(viewmodel, ex));
            }

            return(Ok(viewmodel));
        }
Exemple #6
0
        public IHttpActionResult Get(Int32 eventID)
        {
            TournamentListViewModel viewmodel = new TournamentListViewModel();
            //TournamentDataController dataCtrl = new TournamentDataController();
            EventDataController eventDataCtrl = new EventDataController();

            data.Entity.Event e;
            try { e = eventDataCtrl.GetItem(eventID); }
            catch (Exception ex) { throw new Exception("Fehler beim Laden der Daten (data.Entity.Event)", ex); }

            List <data.Entity.Tournament> tournaments;

            try { tournaments = e.Tournament.ToList(); }
            catch (Exception ex) { throw new Exception("Fehler beim Laden der Daten (data.Entity.Tournament)", ex); }

            if (e.End > DateTime.Now)
            {
                if (tournaments.Count > 0)
                {
                    foreach (var tournament in tournaments)
                    {
                        TournamentViewModelItem item = new TournamentViewModelItem();
                        item.FromModel(tournament);
                        viewmodel.Data.Add(item);
                    }
                }
                else
                {
                    return(Info(viewmodel, "Es wurden keine Turniere für dieses Event angelegt."));
                }
            }
            else
            {
                return(Warning(viewmodel, "Das Event ist vorbei."));
            }

            return(Ok(viewmodel));
        }
        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));
        }