Ejemplo n.º 1
0
        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)
            {
            }
        }
Ejemplo n.º 2
0
        public ActionResult RegisterAuthor(Author author)
        {
            GenreBLL genreBLL = new GenreBLL();

            ViewBag.Genre = genreBLL.List();

            return(View("Register", author));
        }
Ejemplo n.º 3
0
 public GenreForm()
 {
     InitializeComponent();
     genBLL      = new GenreBLL();
     ge          = new Genre();
     gv          = new GenreValidation();
     storedGenre = new List <Genre>();
 }
Ejemplo n.º 4
0
        // GET: Author
        public ActionResult Index(Author author)
        {
            GenreBLL genreBLL = new GenreBLL();

            ViewBag.Genre = genreBLL.List();

            return(View(authorBLL.IList()));
        }
Ejemplo n.º 5
0
        // GET: Genres/Details/5
        public ActionResult Details(int id)
        {
            GenreBLL info = null;

            using (ContextBLL context = new ContextBLL())
            {
                info = context.GenreFindByID(id);
            }
            return(View(info));
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        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());
        }
Ejemplo n.º 8
0
        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));
            }
        }
Ejemplo n.º 9
0
        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));
            }
        }
Ejemplo n.º 10
0
 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)
            {
            }
        }
Ejemplo n.º 12
0
        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);
        }
Ejemplo n.º 13
0
        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"));
        }
Ejemplo n.º 14
0
        public void RemoveGenre(string id)
        {
            GenreBLL genreBLL = new GenreBLL();

            genreBLL.Remove(id);
        }
Ejemplo n.º 15
0
 public GenreController(GenreBLL genreBLL)
 {
     this.genreBLL = genreBLL;
 }
Ejemplo n.º 16
0
 public AuthorController()
 {
     authorBLL   = new AuthorBLL();
     genreBLL    = new GenreBLL();
     bookContext = new BookContext();
 }