public IHttpActionResult Backend_Detail_Insert(Int32 EventID, Int32 SeatNumber, BackendSeatingViewModelItem request) { BackendSeatingViewModel viewmodel = new BackendSeatingViewModel(); // TODO return(Ok(viewmodel)); }
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.")); }
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)); }