Example #1
0
 public void AddSSong(SSong ssong)
 {
     SSongs.Add(ssong);
     SaveChanges();
 }
Example #2
0
 public void RemoveSSong(SSong ssong)
 {
     SSongs.Remove(ssong);
     SaveChanges();
 }
        public ActionResult EditSSong(SSong ssong, HttpPostedFileBase song)
        {
            if (ModelState.IsValid && song != null && ssong.Name != "")
            {
                SSong SSong = null;

                if (ssong.Id == 0)
                {
                    SSong = ssong;
                    SSong.SongMimeType = song.ContentType;
                    SSong.SongData = new byte[song.ContentLength];
                    song.InputStream.Read(SSong.SongData, 0, song.ContentLength);
                    context.AddSSong(SSong);
                }
                else
                {
                    SSong = context.GetSSongById(ssong.Id);
                    SSong.SongMimeType = song.ContentType;
                    SSong.SongData = new byte[song.ContentLength];
                    song.InputStream.Read(SSong.SongData, 0, song.ContentLength);
                }

                context.SaveChanges();
            }
            return Redirect(ControllerContext.HttpContext.Request.UrlReferrer.ToString());
        }