Beispiel #1
0
 public ActionResult Play(int id, song song)
 {
     song.song_view       = song.song_view + 1;
     db.Entry(song).State = EntityState.Modified;
     db.SaveChanges();
     return(View());
 }
Beispiel #2
0
        public async Task <ActionResult> Edit([Bind(Include = "album_id,singer_id,album_name,album_createdate,album_image")] album album, HttpPostedFileBase Upload)
        {
            if (ModelState.IsValid)
            {
                var path = "";
                var file = Request.Files[0];
                if (file != null && file.ContentLength > 0)
                {
                    string _FileName = Path.GetFileName(file.FileName);
                    string _Ext      = Path.GetExtension(file.FileName);
                    path = Path.Combine(Server.MapPath("~/source/images/"), _FileName);
                    // Kiễm tra tồn tại file.
                    if (System.IO.File.Exists(path))
                    {
                        System.IO.File.Delete(path);
                    }
                    album.album_image      = "~/source/images/" + _FileName;
                    album.album_createdate = DateTime.Now;
                    Upload.SaveAs(path);
                }
                db.Entry(album).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.singer_id = new SelectList(db.singers, "singer_id", "singer_name", album.singer_id);
            return(View());
        }
Beispiel #3
0
        public async Task <ActionResult> Edit([Bind(Include = "author_id,author_name")] author author)
        {
            if (ModelState.IsValid)
            {
                db.Entry(author).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(author));
        }
Beispiel #4
0
        public async Task <ActionResult> Edit([Bind(Include = "singer_id,singer_name,singer_nickname,singer_sex,singer_country,singer_image,singer_cover_image,singer_dateofbirth,singer_description")] singer singer)
        {
            if (ModelState.IsValid)
            {
                db.Entry(singer).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(singer));
        }
Beispiel #5
0
        public async Task <ActionResult> Edit([Bind(Include = "genre_id,genre_name")] genre genre)
        {
            if (ModelState.IsValid)
            {
                db.Entry(genre).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(genre));
        }
Beispiel #6
0
        public async Task <ActionResult> Edit([Bind(Include = "user_id,user_name,user_dateofbirth,user_sex,user_address,user_phone,user_image")] user user)
        {
            if (ModelState.IsValid)
            {
                db.Entry(user).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(user));
        }
Beispiel #7
0
        public async Task <ActionResult> Edit([Bind(Include = "playlist_id,user_id,playlist_name,playlist_createdate")] playlist playlist)
        {
            if (ModelState.IsValid)
            {
                db.Entry(playlist).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.user_id = new SelectList(db.users, "user_id", "email", playlist.user_id);
            return(View(playlist));
        }
Beispiel #8
0
        public async Task <ActionResult> Edit([Bind(Include = "album_id,singer_id,album_name,album_createdate,album_image,album_view,album_viewed_day,album_viewed_week,album_viewed_month")] album album)
        {
            if (ModelState.IsValid)
            {
                db.Entry(album).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.singer_id = new SelectList(db.singers, "singer_id", "singer_name", album.singer_id);
            return(View(album));
        }
Beispiel #9
0
        public async Task <ActionResult> Create([Bind(Include = "song_id,album_id,singer_id,author_id,song_name,song_path,song_lyric,song_image,song_view,song_viewed_day,song_viewed_week,song_viewed_month,song_download,song_downloaded_week,song_downloaded_month,song_datemodify")] song song, HttpPostedFileBase SUpload)
        {
            if (ModelState.IsValid)
            {
                if (song.song_name == null)
                {
                    ModelState.AddModelError("", "Mời nhập tên bài hát- Tên bài hát không được trống");
                }
                var file = Request.Files[0];
                if (file != null && file.ContentLength > 0)
                {
                    var _FileName = Path.GetFileName(file.FileName);
                    var _Ext      = Path.GetExtension(file.FileName);
                    var path      = Path.Combine(Server.MapPath("~/source/audio/"), _FileName + "");
                    song.song_path = "~/source/audio/" + _FileName;
                    if (System.IO.File.Exists(path))
                    {
                        var _NewName = Guid.NewGuid();
                        _FileName      = _NewName.ToString();
                        path           = Path.Combine(Server.MapPath("~/source/audio/"), _NewName + _Ext);
                        song.song_path = "~/source/audio/" + _NewName + _Ext;
                    }
                    SUpload.SaveAs(path);
                }
                if (song.song_lyric == null)
                {
                    song.song_lyric = "Chưa cập nhật";
                }
                song.song_view       = 1;
                db.Entry(song).State = EntityState.Added;
                song.song_datemodify = DateTime.Now;

                db.songs.Add(song);
                await db.SaveChangesAsync();
            }
            ViewBag.album_id  = new SelectList(db.albums, "album_id", "album_name", song.album_id);
            ViewBag.author_id = new SelectList(db.authors, "author_id", "author_name", song.author_id);
            ViewBag.singer_id = new SelectList(db.singers, "singer_id", "singer_name", song.singer_id);
            return(RedirectToAction("Index"));
        }