public ActionResult Create(Album album) { if (ModelState.IsValid) { //db.Albums.Add(album); //db.SaveChanges(); _albums.Add(album); _unitOfWork.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.GenreId = new SelectList(_genres.Get(), "GenreId", "Name", album.GenreId); ViewBag.ArtistId = new SelectList(_artists.Get(), "ArtistId", "Name", album.ArtistId); return(View(album)); }
public OperationStatus Add(Album album) { var status = new OperationStatus(); if (_repository.IsAlbumExist(album.Name, album.UserId)) { status.ErrorMessage = "Album with such name is already exists"; return(status); } _repository.Add(album); status.IsSuccessful = true; return(status); }