public IHttpActionResult AcceptTransfer(Int32 ID)
        {
            BaseViewModel      viewmodel    = new BaseViewModel();
            SeatDataController seatDataCtrl = new SeatDataController();

            try
            {
                Seat seat = seatDataCtrl.GetItem(ID);

                if (seat.TransferUserID == null)
                {
                    return(Error(viewmodel, "Der Platz wurde nicht transferiert."));
                }

                if (seat.TransferUserID != UserHelper.CurrentUserID)
                {
                    return(Warning(viewmodel, "Der Platz wurde dir nicht zugesendet."));
                }

                seat.UserID         = seat.TransferUserID ?? default(int);
                seat.TransferUserID = null;
                seatDataCtrl.Update(seat);
            }
            catch (Exception ex)
            {
                return(Error(viewmodel, ex));
            }

            return(Ok(viewmodel, "Transfer wurde durchgeführt."));
        }
        public IHttpActionResult TransferReservation(TransferReservationRequest request)
        {
            BaseViewModel      viewmodel    = new BaseViewModel();
            UserDataController dataCtrl     = new UserDataController();
            SeatDataController seatDataCtrl = new SeatDataController();

            try
            {
                Int32 TransferUserID;
                Seat  seat = seatDataCtrl.GetItem(request.SeatID);
                try
                {
                    TransferUserID = dataCtrl.GetItems().Single(x => x.Email == request.Email).ID;
                }
                catch (Exception)
                {
                    return(Warning(viewmodel, "Die Email wurde nicht vergeben."));
                }

                if (TransferUserID == UserHelper.CurrentUserID)
                {
                    return(Warning(viewmodel, "Du kannst keine Tickets an dich selber versenden."));
                }

                if (seat.UserID != UserHelper.CurrentUserID)
                {
                    return(Warning(viewmodel, "Du bist nicht Inhaber dieses Tickets."));
                }

                if (dataCtrl.ValidateUser(UserHelper.CurrentUserEmail, request.Password))
                {
                    seat.TransferUserID = TransferUserID;
                    seatDataCtrl.Update(seat);
                }
                else
                {
                    return(Warning(viewmodel, "Das eingegebene Passwort stimmt nicht."));
                }
            }
            catch (Exception ex)
            {
                return(Error(viewmodel, ex));
            }

            return(Ok(viewmodel, "Ticket wurde versendet."));
        }
        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."));
        }