/// <summary> /// Deprecated Method for adding a new object to the Songs EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToSongs(Song song) { base.AddObject("Songs", song); }
/// <summary> /// Create a new Song object. /// </summary> /// <param name="songID">Initial value of the SongID property.</param> /// <param name="name">Initial value of the Name property.</param> /// <param name="artist">Initial value of the Artist property.</param> public static Song CreateSong(global::System.Guid songID, global::System.String name, global::System.String artist) { Song song = new Song(); song.SongID = songID; song.Name = name; song.Artist = artist; return song; }
public CreateSongVM(Song song) { Song = song; Reports = new ChwinockEntities().Reports; }
public ActionResult CreateSong(CreateSongVM model, List<String> AssociatedReports) { var db = new ChwinockEntities(); var newSong = new Song(); newSong.SongID = Guid.NewGuid(); newSong.Artist = model.Song.Artist; newSong.Name = model.Song.Name; newSong.Url = model.Song.Url; if (AssociatedReports != null) { foreach (var r in AssociatedReports) { var id = Guid.Parse(r); newSong.Reports.Add(db.Reports.Single(x => x.ReportID == id)); } } db.Songs.AddObject(newSong); db.SaveChanges(); return RedirectToAction("Manage"); }
//Constructors public CreateSongVM() { Song = new Song(); Reports = new ChwinockEntities().Reports; }