public JsonResult SaveSong(Song song)
 {
     int compID = Convert.ToInt32(System.Web.HttpContext.Current.Session["CompositionID"] as string);
     using (var db = new CompositionContext())
     {
         Composition c;
         if (compID == 0)
         {
             c = new Composition();
         }
         else
         {
             c = db.Compositions.Find(compID);
         }
         song.getMetaData(c);
         c.Content = song.getContent();
         c.TabContent = song.getTabContent();
         c.User = User.Identity.Name;
        if (compID == 0)
         {
             db.Compositions.Add(c);
         }
         db.SaveChanges();
         song.setMetaData(c);
         song.SongId = c.CompositionID;
     }
     foreach (var p in song.Pages)
     {
         while (p.Measures.Count() < 28)
         {
             p.Measures.Add(new Measure());
         }
     }
     return Json(song, JsonRequestBehavior.AllowGet);
 }
        public ActionResult GetSong()
        {
            Song song = new Song();
            if (System.Web.HttpContext.Current.Session["CompositionID"] as string == "0")
            {
                song.Pages.Add(new Page());
                song.Artist = "N/A";
                song.Title = "New Song";
                song.Author = "N/A";
                song.BeatsPerMeasure = 4;
                song.Difficulty = "Easy";
                song.SingleBeat = 4;
                song.KeySignature = "C";
            }
            else
            {
                Composition c;
                int compID = Convert.ToInt32(System.Web.HttpContext.Current.Session["CompositionID"] as string);
                using (var db = new CompositionContext())
                {
                    c = db.Compositions.Where(x => x.CompositionID == compID).Single();
                    song.setMetaData(c);
                    song.setContent(c.Content, c.TabContent);
                }
            }

            return Json(song, JsonRequestBehavior.AllowGet);
        }
 public ActionResult GetSongFromComposition(Composition c)
 {
     Song song = new Song();
     using (var db = new CompositionContext())
     {
         song.setMetaData(c);
         song.setContent(c.Content, c.TabContent);
     }
     return Json(song, JsonRequestBehavior.AllowGet);
 }
 public ActionResult UsersFiles()
 {
     List<Composition> files = new List<Composition>();
     using (var db = new CompositionContext())
     {
         files = db.Compositions.Where(x => x.User == User.Identity.Name).ToList<Composition>();
         foreach (Composition c in files)
         {
             c.Content = "";
             c.TabContent = "";
         }
     }
     return PartialView(files);
 }
 public ActionResult Search(string searchBy, string search)
 {
     List<Composition> files = new List<Composition>();
     using (var db = new CompositionContext())
     {
         if (searchBy == "Difficulty" || searchBy == null)
         {
             if (search == null)
                 files = db.Compositions.Where(x => x.Difficulty == "Easy").ToList<Composition>();
             else
                 files = db.Compositions.Where(x => x.Difficulty == search).ToList<Composition>();
         }
         else
         {
             files = db.Compositions.Where(x => x.Title == search).ToList<Composition>();
         }
     }
     return PartialView(files);
 }