public IHttpActionResult Backend_Detail_Update(Int32 id, BackendTournamentViewModelItem request) { BackendTournamentViewModel viewmodel = new BackendTournamentViewModel(); TournamentDataController dataCtrl = new TournamentDataController(); TournamentGameDataController gameDataCtrl = new TournamentGameDataController(); EventDataController eventDataCtrl = new EventDataController(); try { viewmodel.EventOptions = eventDataCtrl.GetItems().ToList().ConvertAll(x => { return(new BackendEventViewModelItem().FromModel(x)); }).OrderByDescending(x => x.ID).ToList(); viewmodel.GameOptions = gameDataCtrl.GetItems().ToList().ConvertAll(x => { return(new BackendGameViewModelItem().FromModel(x)); }).OrderBy(x => x.Name).ToList(); var data = dataCtrl.Update(request.ToModel()); viewmodel.Data.FromModel(data); } catch (Exception ex) { return(Error(viewmodel, ex)); } return(Ok(viewmodel, "Speichern erfolgreich.")); }
public IHttpActionResult Backend_Detail_New() { BackendTournamentViewModel viewmodel = new BackendTournamentViewModel(); TournamentGameDataController gameDataCtrl = new TournamentGameDataController(); EventDataController eventDataCtrl = new EventDataController(); try { viewmodel.EventOptions = eventDataCtrl.GetItems().ToList().ConvertAll(x => { return(new BackendEventViewModelItem().FromModel(x)); }).OrderByDescending(x => x.ID).ToList(); viewmodel.GameOptions = gameDataCtrl.GetItems().ToList().ConvertAll(x => { return(new BackendGameViewModelItem().FromModel(x)); }).OrderBy(x => x.Name).ToList(); viewmodel.Data.Event = viewmodel.EventOptions[0]; viewmodel.Data.Start = viewmodel.Data.Event.Start; } catch (Exception ex) { return(Error(viewmodel, ex)); } return(Ok(viewmodel)); }