public ActionResult EndUserEdit(SongViewModel song) { var part = new SongPartRecord { Id = song.SongPartRecordId, SongTitle = song.SongTitle, SongAuthor = song.SongAuthor, SongUrl = song.SongUrl, SongDescription = song.SongDescription, SongThumbnailUrl = song.SongThumbnailUrl, PollChoiceRecord_Id = song.PollChoiceRecord_Id, Shown = true, SongEditorUserName = song.SongEditorUserName, SongEditorUserItemId = song.SongEditorUserItemId, SubmittedDateUtc = DateTime.UtcNow }; // Catch song category choice from chosen radio button value switch (HttpContext.Request.Params.Get("SongCategory")) { case ("Original"): { part.SongCategory = SongCategory.Original; } break; case ("Cowrite"): // "2" { part.SongCategory = SongCategory.Cowrite; } break; case ("IntOriginal"): // "3" { part.SongCategory = SongCategory.IntOriginal; } break; case ("IntCowrite"): // "4" { part.SongCategory = SongCategory.IntCowrite; } break; default: part.SongCategory = SongCategory.Original; break; } // Update Poll Choice Record, if Song Author or Song Title has changed var pollChoiceRecord = _choiceRepository.Fetch(c => c.Id == song.PollChoiceRecord_Id).FirstOrDefault(); if (pollChoiceRecord != null) { pollChoiceRecord.Answer = part.SongTitle + " (" + part.SongAuthor + ")"; _pollService.UpdateChoice(pollChoiceRecord); } _songService.UpdateSong(part); Services.Notifier.Information(T("Din sang er nu redigeret")); return(Redirect("~/Afstemninger/Liste")); }
public SongEntry CreateSongEntry(SongPartRecord song) { if (song == null) { throw new ArgumentNullException("song"); } return(new SongEntry { Song = song, IsChecked = false }); }
public ActionResult EditSongUrlFromAdminPanel(SongUrlViewModel songUrlVM) { var songPart = _songService.GetSong(songUrlVM.SongPartRecordId); var part = new SongPartRecord { // populate from posted form Id = songUrlVM.SongPartRecordId, SongTitle = songUrlVM.SongTitle, SongAuthor = songUrlVM.SongAuthor, SongUrl = songUrlVM.SongUrl, SongDescription = songUrlVM.SongDescription, // populate from part record fetch SongThumbnailUrl = songPart.SongThumbnailUrl, PollChoiceRecord_Id = songPart.PollChoiceRecord_Id, Shown = true, SongEditorUserName = songPart.SongEditorUserName, SongEditorUserItemId = songPart.SongEditorUserItemId, // hard code category to ''original' for now SongCategory = SongCategory.Original, // Set submitted datetime SubmittedDateUtc = DateTime.UtcNow }; // Update Poll Choice Record, if Song Author or Song Title has changed var pollChoiceRecord = _choiceRepository.Fetch(c => c.Id == songPart.PollChoiceRecord_Id).FirstOrDefault(); if (pollChoiceRecord != null) { pollChoiceRecord.Answer = part.SongTitle + " (" + part.SongAuthor + ")"; _pollService.UpdateChoice(pollChoiceRecord); } _songService.UpdateSong(part); Services.Notifier.Information(T("Sangen er nu redigeret")); return(RedirectToAction("SongIndex", "Admin")); }
public void EditSong(SongPart part, SongViewModel model) { if (part == null) { throw new ArgumentNullException("part"); } if (model == null) { throw new ArgumentNullException("model"); } var song = new SongPartRecord { Id = part.Record.ContentItemRecord.Id, SongTitle = model.SongTitle, SongAuthor = model.SongAuthor, SongUrl = model.SongUrl, SongDescription = model.SongDescription, ContentItemRecord = part.Record.ContentItemRecord }; switch (model.SongCategory) { case ("Original"): // "1" { song.SongCategory = SongCategory.Original; } break; case ("Cowrite"): // "2" { song.SongCategory = SongCategory.Cowrite; } break; case ("IntOriginal"): // "3" { song.SongCategory = SongCategory.IntOriginal; } break; case ("IntCowrite"): // "4" { song.SongCategory = SongCategory.IntCowrite; } break; default: song.SongCategory = SongCategory.Original; break; } // slet den gamle Poll Choice Record var oldPollChoiceRecord = _choiceRepository.Fetch(r => r.Id == part.PollChoiceRecord_Id).FirstOrDefault(); if (oldPollChoiceRecord != null) { _pollService.DeleteChoice(oldPollChoiceRecord); } var pollId = Convert.ToInt32(model.SelectedPollId); var choice = new PollChoiceRecord { Answer = song.SongTitle, PollPartRecord = _pollService.GetPoll(pollId) }; _pollService.CreateChoice(choice); // First, get all the poll choices in an ordered list. // then, set PollChoiceRecord_Id to the last choice item in poll, the newest addition. Best we can do.. var choices = _pollService.GetOrderedChoices(pollId); if (choices.Count() >= 1) { song.PollChoiceRecord_Id = choices.Last().Id; } UpdateSong(song); }
public void UpdateSong(SongPartRecord song) { _songRepository.Update(song); }
public ActionResult EditFromAdminPanel(SongViewModel song) { var part = new SongPartRecord { Id = song.SongPartRecordId, SongTitle = song.SongTitle, SongAuthor = song.SongAuthor, SongUrl = song.SongUrl, SongDescription = song.SongDescription, SongThumbnailUrl = song.SongThumbnailUrl, PollChoiceRecord_Id = song.PollChoiceRecord_Id, Shown = true, SongEditorUserName = song.SongEditorUserName, SongEditorUserItemId = song.SongEditorUserItemId, SubmittedDateUtc = DateTime.UtcNow }; // Catch song category choice from chosen radio button value switch (HttpContext.Request.Params.Get("SongCategory")) { case ("Original"): { part.SongCategory = SongCategory.Original; } break; case ("Cowrite"): // "2" { part.SongCategory = SongCategory.Cowrite; } break; case ("IntOriginal"): // "3" { part.SongCategory = SongCategory.IntOriginal; } break; case ("IntCowrite"): // "4" { part.SongCategory = SongCategory.IntCowrite; } break; default: part.SongCategory = SongCategory.Original; break; } // slet den gamle Poll Choice Record var oldPollChoiceRecord = _choiceRepository.Fetch(c => c.Id == song.PollChoiceRecord_Id).FirstOrDefault(); if (oldPollChoiceRecord != null) { _pollService.DeleteChoice(oldPollChoiceRecord); } // opret ny poll choice record, linked til den valgte poll id fra selectlisten var pollId = Convert.ToInt32(song.SelectedPollId); var choice = new PollChoiceRecord { Answer = song.SongTitle + " (" + song.SongAuthor + ")", PollPartRecord = _pollService.GetPoll(pollId) }; _pollService.CreateChoice(choice); // set PollChoiceRecord_Id to the last choice item in poll, the newest addition. Best we can do.. var choices = _pollService.GetChoices(pollId); if (choices.Count() >= 1) { // re-order the random shuffle, so the last in sequence is indeed the last in sequence choices = choices.OrderBy(c => c.Id).AsQueryable <PollChoiceRecord>(); part.PollChoiceRecord_Id = choices.Last().Id; } _songService.UpdateSong(part); var songContentItem = _contentManager.Get(part.Id, VersionOptions.Latest); var songPart = songContentItem.As <SongPart>(); var model = new SongViewModel(songPart); Services.Notifier.Information(T("Sangen er nu redigeret")); // return View("EditorTemplates/Parts/SongForm", model); // return View("Parts/Song", model); return(RedirectToAction("SongIndex", "Admin")); // var songViewModel = Shape.Parts_Song(part); // return new ShapeResult(this, songViewModel(typeof(SongViewModel))); //return Redirect("~/Afstemninger/Liste"); }