Example #1
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Song EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToSong(Song song)
 {
     base.AddObject("Song", song);
 }
Example #2
0
        public ActionResult AddSongToProject(Song model, int projectId, HttpPostedFileBase fileUpload)
        {
            using (var context = new SiteContainer())
            {
                var project = context.Project.First(p => p.Id == projectId);
                var file = fileUpload;
                if (file != null)
                {

                    var pi = new Song();
                    string fileName = IOHelper.GetUniqueFileName("~/Content/Music/mp3", file.FileName);
                    string filePath = Server.MapPath("~/Content/Music/mp3");
                    filePath = Path.Combine(filePath, fileName);
                    file.SaveAs(filePath);
                    pi.FileName = fileName;
                    pi.Title = model.Title;
                    project.Songs.Add(pi);
                    context.SaveChanges();
                }
                return RedirectToAction("Projects", "Home", new { area = "", id = project.Name });
            }
        }
Example #3
0
 /// <summary>
 /// Create a new Song object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="title">Initial value of the Title property.</param>
 /// <param name="fileName">Initial value of the FileName property.</param>
 /// <param name="projectId">Initial value of the ProjectId property.</param>
 public static Song CreateSong(global::System.Int32 id, global::System.String title, global::System.String fileName, global::System.Int32 projectId)
 {
     Song song = new Song();
     song.Id = id;
     song.Title = title;
     song.FileName = fileName;
     song.ProjectId = projectId;
     return song;
 }