private void BindGenre() { try { genreBllList = new GenreBLL(); Genre g = new Genre(); genreList = genreBllList.GetAll(); if (genreList.Count > 0) { g = genreList[0]; genreList[0] = new Genre() { GenreId = 0, _Genre = "Other", isActive = true }; genreList.Add(g); comboGenre.DataSource = genreList.Where(x => x.isActive == true).ToList(); comboGenre.DisplayMember = "_Genre"; } else { genreList = new List <Genre>(); genreList.Add(new Genre() { GenreId = 0, _Genre = "Other", isActive = true }); comboGenre.DataSource = genreList; comboGenre.DisplayMember = "_Genre"; } } catch (Exception) { } }
public ActionResult RegisterAuthor(Author author) { GenreBLL genreBLL = new GenreBLL(); ViewBag.Genre = genreBLL.List(); return(View("Register", author)); }
public GenreForm() { InitializeComponent(); genBLL = new GenreBLL(); ge = new Genre(); gv = new GenreValidation(); storedGenre = new List <Genre>(); }
// GET: Author public ActionResult Index(Author author) { GenreBLL genreBLL = new GenreBLL(); ViewBag.Genre = genreBLL.List(); return(View(authorBLL.IList())); }
// GET: Genres/Details/5 public ActionResult Details(int id) { GenreBLL info = null; using (ContextBLL context = new ContextBLL()) { info = context.GenreFindByID(id); } return(View(info)); }
public void UpdateGenre(int id, string name, string description, DateTime date) { GenreBLL genreBLL = new GenreBLL(); Genre genre = new Genre(); genre.Id = id; genre.Name = name; genre.Description = description; genre.DateCreate = date; genreBLL.Update(genre); }
public ActionResult Index() { AuthorBLL author = new AuthorBLL(); BookBLL book = new BookBLL(); GenreBLL genre = new GenreBLL(); ViewBag.ContAuthor = author.IList().Count(); ViewBag.ContGenre = genre.List().Count(); ViewBag.ContBook = book.List().Count(); return(View()); }
public ActionResult Edit(int id, GenreBLL collection) { try { using (ContextBLL context = new ContextBLL()) { context.GenreUpdateJust(id, collection.GenreName); } // TODO: Add update logic here return(RedirectToAction("Index")); } catch (Exception ex) { Logger.Log(ex); return(View("Error", ex)); } }
public ActionResult Create(GenreBLL collection) { try { using (ContextBLL context = new ContextBLL()) { context.GenreCreate(collection.GenreName); } // TODO: Add insert logic here return(RedirectToAction("Index")); } catch (Exception ex) { Logger.Log(ex); return(View("Error", ex)); } }
public ActionResult Delete(int id, GenreBLL collection) { try { // TODO: Add delete logic here using (ContextBLL context = new ContextBLL()) { context.GenreDelete(id); } return(RedirectToAction("Index")); } catch (Exception ex) { Logger.Log(ex); return(View("Error", ex)); } }
private void BindGenre(Genre genre) { try { genreBllList = new GenreBLL(); Genre g = new Genre(); genreList = genreBllList.GetAll(); if (genreList.Count > 0) { g = genreList[0]; genreList[0] = genre; genreList.Add(g); comboGenre.DataSource = genreList.ToList(); comboGenre.DisplayMember = "_Genre"; } } catch (Exception) { } }
public void UpdateGenre(GenreBLL genreBLL, IEnumerable <TrackBLL> tracksBLL, IEnumerable <AlbumBLL> albumsBLL, IEnumerable <AuthorBLL> authorsBLL) { Mapper.Initialize(cfg => cfg.CreateMap <GenreBLL, Genre>()); Genre genre = Mapper.Map <GenreBLL, Genre>(genreBLL); if (albumsBLL != null) { Mapper.Initialize(cfg => cfg.CreateMap <AlbumBLL, Album>()); genre.Albums = Mapper.Map <IEnumerable <AlbumBLL>, IEnumerable <Album> >(albumsBLL).ToList(); } if (tracksBLL != null) { Mapper.Initialize(cfg => cfg.CreateMap <TrackBLL, Track>()); genre.Tracks = Mapper.Map <IEnumerable <TrackBLL>, IEnumerable <Track> >(tracksBLL).ToList(); } if (authorsBLL != null) { Mapper.Initialize(cfg => cfg.CreateMap <AuthorBLL, Author>()); genre.Authors = Mapper.Map <IEnumerable <AuthorBLL>, IEnumerable <Author> >(authorsBLL).ToList(); } TracksDB.Genres.Update(genre); }
public ActionResult Upload(IEnumerable <HttpPostedFileBase> upload, string genreName) { if (upload != null) { byte[] b = new byte[128]; string titleFromStream; string authorFromStream; string albumFromStream; foreach (var track in upload) { byte[] trackByteArray = new byte[track.ContentLength]; track.InputStream.Read(trackByteArray, 0, trackByteArray.Length); track.InputStream.Seek(-128, SeekOrigin.End); track.InputStream.Read(b, 0, 128); bool isSet = false; String sFlag = System.Text.Encoding.Default.GetString(b, 0, 3); if (sFlag.CompareTo("TAG") == 0) { isSet = true; } if (isSet) { titleFromStream = System.Text.Encoding.Default.GetString(b, 3, 30); titleFromStream = titleFromStream.Replace("\0", string.Empty); var uniqueFilePath = string.Format(@"/files/{0}.mp3", DateTime.Now.Ticks); try { track.SaveAs(Server.MapPath(uniqueFilePath)); } catch (Exception ex) { Console.Write(ex.Message); break; } authorFromStream = System.Text.Encoding.Default.GetString(b, 33, 30); authorFromStream = authorFromStream.Replace("\0", string.Empty); albumFromStream = System.Text.Encoding.Default.GetString(b, 63, 30); albumFromStream = albumFromStream.Replace("\0", string.Empty); TrackBLL newTrack = new TrackBLL { TrackName = titleFromStream, TrackLocation = uniqueFilePath }; AuthorBLL author = new AuthorBLL { AuthorName = authorFromStream }; AlbumBLL album = new AlbumBLL() { AlbumName = albumFromStream }; List <GenreBLL> genres = new List <GenreBLL>(); GenreBLL genre = new GenreBLL() { GenreName = genreName }; genres.Add(genre); try { dbMod.CreateTrack(newTrack, author, genres, album); RedirectToAction("Upload"); } catch { System.IO.File.Delete(Server.MapPath(uniqueFilePath)); } } } } return(RedirectToAction("Index")); }
public void RemoveGenre(string id) { GenreBLL genreBLL = new GenreBLL(); genreBLL.Remove(id); }
public GenreController(GenreBLL genreBLL) { this.genreBLL = genreBLL; }
public AuthorController() { authorBLL = new AuthorBLL(); genreBLL = new GenreBLL(); bookContext = new BookContext(); }