Esempio n. 1
0
        public ActionResult AddSong(SongViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                if (_db.Songs.FirstOrDefault(I => I.Title == viewModel.Title) == null)
                {
                    var song = new Song();
                    song.Title = viewModel.Title;
                    song.Writer = viewModel.Writer;
                    song.Genre = viewModel.Genre;
                    song.Tone = viewModel.Tone;
                    song.Rhythm = viewModel.Rhythm;
                    song.Body = viewModel.Body;
                    song.CreatedBy = User.Identity.Name;

                    _db.AddSong(song);
                    _db.Save();

                    return RedirectToAction("index", "home");
                }
                else
                {
                    ViewBag.Message = "Bản nhạc này đã có rồi.";
                }
            }

            return View(viewModel);
        }
Esempio n. 2
0
 void ISongDataSource.AddSong(Song song)
 {
     Songs.Add(song);
 }