Ejemplo n.º 1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            AuthorModel author = new AuthorModel(TextBox1.Text, TextBox2.Text);

            Response.Write(AuthorBLL.AddAuthor(author));
            Label1.Text = AuthorBLL.GetAuthorCount().ToString();
        }
Ejemplo n.º 2
0
        PersonBLLCollection CreatePersonBLLCollection()
        {
            PersonBLLCollection people  = new PersonBLLCollection();
            AuthorBLL           author1 = new AuthorBLL()
            {
                ID        = 1,
                FirstName = "Sam",
                LastName  = "Jacobs"
            };
            AuthorBLL author2 = new AuthorBLL()
            {
                ID        = 2,
                FirstName = "Fran",
                LastName  = "Heathwood"
            };
            AuthorBLL author3 = new AuthorBLL()
            {
                ID        = 3,
                FirstName = "Tom",
                LastName  = "Marrows"
            };
            AuthorBLL author4 = new AuthorBLL()
            {
                ID        = 4,
                FirstName = "Karen",
                LastName  = "Flint"
            };

            people.Add(author1);
            people.Add(author2);
            people.Add(author3);
            people.Add(author4);

            return(people);
        }
Ejemplo n.º 3
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (dgvAuthor.SelectedCells.Count > 0)
            {
                int             selectedrowindex = dgvAuthor.SelectedCells[0].RowIndex;
                DataGridViewRow selectedRow      = dgvAuthor.Rows[selectedrowindex];
                int             id     = Convert.ToInt32(selectedRow.Cells["clmnId"].Value);
                DialogResult    result = MessageBox.Show("Do you want to delete author: " + selectedRow.Cells["clmnName"].Value + "?", "Warning", MessageBoxButtons.OKCancel);
                switch (result)
                {
                case DialogResult.Cancel:
                    break;

                case DialogResult.OK:
                    AuthorBLL authorBLL = new AuthorBLL(Convert.ToInt32(selectedRow.Cells["clmnId"].Value), selectedRow.Cells["clmnName"].Value.ToString(), selectedRow.Cells["clmnWorkPlace"].Value.ToString());
                    if (AuthorDAL.getAuthorItem(authorBLL) != null)
                    {
                        MessageBox.Show("Can't delete! Please delete all book of " + selectedRow.Cells["clmnName"].Value + " before delete this author!", "Error");
                        break;
                    }
                    else
                    {
                        AuthorDAL.deleteAuthor(authorBLL);
                        MessageBox.Show("Delete complete!", "Success");
                        this.LoadDataToGridView();
                        break;
                    }
                }
            }
        }
Ejemplo n.º 4
0
 public frmKitapEkle()
 {
     InitializeComponent();
     _bookBLL      = new BookBLL();
     _publisherBLL = new PublisherBLL();
     _authorBLL    = new AuthorBLL();
 }
Ejemplo n.º 5
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            string key     = this.txtSearch.Text;
            string catalog = "";

            if (key == "".Trim())
            {
                MessageBox.Show("Please enter keyword!", "Notice");
                return;
            }
            if (this.cboSearch.SelectedItem.ToString() == "Work Place")
            {
                catalog = "noicongtac";
            }
            else
            {
                catalog = "tentacgia";
            }
            AuthorBLL        authorBLL = new AuthorBLL();
            List <AuthorBLL> authorArr = new List <AuthorBLL>();

            authorArr = AuthorDAL.search(catalog, key);
            this.dgvAuthor.Rows.Clear();
            foreach (AuthorBLL row in authorArr)
            {
                this.dgvAuthor.Rows.Add(row.AuthorId, row.Name, row.WorkPlace);
            }
            this.GetSelectedValue();

            this.dgvAuthor.CellClick += new DataGridViewCellEventHandler(dgvAuthor_CellClick);
        }
Ejemplo n.º 6
0
        public ActionResult Details(int Id)
        {
            TrackBLL dbTrack = dbGet.GetTrack(Id);

            Mapper.Initialize(cfg => cfg.CreateMap <TrackBLL, TrackViewModel>());
            TrackViewModel track = Mapper.Map <TrackBLL, TrackViewModel>(dbTrack);

            IEnumerable <TrackRateBLL> trackRates = dbGet.GetTrackRate(dbTrack.TrackName);

            ViewBag.TrackRates = trackRates;


            if (dbTrack.AuthorID != null)
            {
                AuthorBLL authorBLL = dbGet.GetAuthor((int)dbTrack.AuthorID);
                Mapper.Initialize(cfg => cfg.CreateMap <AuthorBLL, AuthorViewModel>());
                AuthorViewModel author = Mapper.Map <AuthorBLL, AuthorViewModel>
                                             (authorBLL);
                ViewBag.Author = author;
                return(PartialView(track));
            }
            else
            {
                return(PartialView("Details2", track));
            }
        }
Ejemplo n.º 7
0
 public FormBookInfo()
 {
     InitializeComponent();
     BookController            = new BookBLL();
     AuthorController          = new AuthorBLL();
     CategoryController        = new CategoryBLL();
     ImportBookCarllController = new ImportBookCardBLL();
 }
Ejemplo n.º 8
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         Label1.Text = AuthorBLL.GetAuthorCount().ToString();
         Label2.Text = PublisherBLL.GetPublisherCount().ToString();
     }
 }
Ejemplo n.º 9
0
        public ActionResult Create()
        {
            var bookViewModel = new BookDetailsViewModel();

            bookViewModel.PublisherList = PublisherBLL.ListAll();
            bookViewModel.AuthorsList   = AuthorBLL.ListAll();
            return(View(bookViewModel));
        }
        // DELETE: api/Author/5
        public HttpResponseMessage Delete(int id)
        {
            if (!AuthorBLL.DeleteAuthor(id))
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError));
            }

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
Ejemplo n.º 11
0
 private void setSelectedValueComboboxAuthor(AuthorBLL authorBLL)
 {
     foreach (ComboboxItem item in this.cboAuthor.Items)
     {
         if (Convert.ToInt32(item.Value) == authorBLL.AuthorId)
         {
             this.cboAuthor.SelectedItem = item;
         }
     }
 }
        public FormCategoryAndAuthorData()
        {
            InitializeComponent();
            AuthorController = new AuthorBLL();
            listAuthor       = new List <Author>();

            categoryController = new CategoryBLL();
            listCategories     = new List <Category>();

            ClearAndLoad();
        }
        public HttpResponseMessage GetByBook(int id)
        {
            var Authors = AuthorBLL.GetAuhtorsByBooks(id);

            if (Authors == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound, id));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, Authors));
        }
        // GET: api/Author/5
        public HttpResponseMessage Get(int id)
        {
            var Author = AuthorBLL.GetAutorBy(id);

            if (Author == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound, id));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, Author));
        }
        // GET: api/Author
        public HttpResponseMessage Get()
        {
            var Books = AuthorBLL.GetAuthors();

            if (Books == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, Books));
        }
        // PUT: api/Author/5
        public HttpResponseMessage Put(int id, [FromBody] AuthorEntity entity)
        {
            var author = AuthorBLL.UpdateAuthor(id, entity);

            if (author == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            return(Request.CreateResponse(HttpStatusCode.Created, author));
        }
Ejemplo n.º 17
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.º 18
0
        public static AuthorBLL getAuthorItem(AuthorBLL authorBLL)
        {
            String    sql = "SELECT * FROM [tacgia] WHERE matacgia=" + authorBLL.AuthorId;
            DataTable dt  = TypeOfBookDAL._condb.getDataTable(sql);

            if (dt.Rows.Count > 0)
            {
                DataRow row = dt.Rows[0];
                return(new AuthorBLL(Int32.Parse(row["matacgia"].ToString()), row["tentacgia"].ToString(), row["noicongtac"].ToString()));
            }
            return(null);
        }
Ejemplo n.º 19
0
        public static List <AuthorBLL> search(string catalog, string key)
        {
            string           sql        = "SELECT * FROM [tacgia] WHERE " + catalog + " LIKE '%" + key + "%'";
            DataTable        dt         = AuthorDAL._condb.getDataTable(sql);
            List <AuthorBLL> authorList = new List <AuthorBLL>();

            foreach (DataRow row in dt.Rows)
            {
                AuthorBLL authorBLL = new AuthorBLL(Int32.Parse(row["matacgia"].ToString()), row["tentacgia"].ToString(), row["noicongtac"].ToString());
                authorList.Add(authorBLL);
            }
            return(authorList);
        }
Ejemplo n.º 20
0
        public void UpdateAuthor(int id, string name, int idGenre, string mainSaga, string favoriteBook, DateTime date)
        {
            AuthorBLL authorBLL = new AuthorBLL();
            Author    author    = new Author();

            author.Id           = id;
            author.Name         = name;
            author.IdGenre      = idGenre;
            author.MainSaga     = mainSaga;
            author.FavoriteBook = favoriteBook;
            author.DateCreate   = date;

            authorBLL.Update(author);
        }
Ejemplo n.º 21
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            AuthorBLL authorBLL = new AuthorBLL();

            authorBLL.Name      = this.txtAuthorName.Text;
            authorBLL.WorkPlace = this.txtWorkPlace.Text;
            if (authorBLL.Name == "")
            {
                MessageBox.Show("Author name is not null!", "Notice");
                return;
            }
            AuthorDAL.addAuthor(authorBLL);
            MessageBox.Show("Add success!", "Success");
            this.LoadDataToGridView();
        }
Ejemplo n.º 22
0
        public ActionResult Create(BookDetailsViewModel bookViewModel)
        {
            if (ModelState.IsValid)
            {
                var bookModel = this.ConvertBookDetailsViewModelToBookModel(bookViewModel);

                BookBLL.Insert(bookModel);
                return(RedirectToAction("Index"));
            }

            bookViewModel.PublisherList = PublisherBLL.ListAll();
            bookViewModel.AuthorsList   = AuthorBLL.ListAll();

            return(View(bookViewModel));
        }
Ejemplo n.º 23
0
        public AddBook()
        {
            InitializeComponent();
            //this.StartPosition = FormStartPosition.Manual;
            //this.Location = new Point(0, 0);

            //init properties
            AuthorController   = new AuthorBLL();
            CategoryController = new CategoryBLL();
            AuthorsList        = new List <Button>();
            RemovedButton      = new Button();
            BookController     = new BookBLL();

            //LoadData();
            //LoadEventForListAuthors();
        }
Ejemplo n.º 24
0
        public static List <AuthorBLL> getAuthorList()
        {
            string    sql = "SELECT * FROM [tacgia]";
            DataTable dt  = AuthorDAL._condb.getDataTable(sql);

            if (dt.Rows.Count > 0)
            {
                List <AuthorBLL> authorList = new List <AuthorBLL>();
                foreach (DataRow row in dt.Rows)
                {
                    AuthorBLL authorBLL = new AuthorBLL(Int32.Parse(row["matacgia"].ToString()), row["tentacgia"].ToString(), row["noicongtac"].ToString());
                    authorList.Add(authorBLL);
                }
                return(authorList);
            }
            return(null);
        }
Ejemplo n.º 25
0
        public void UpdateTrack(TrackBLL trackBLL, AuthorBLL authorBLL, IEnumerable <GenreBLL> genresBLL, AlbumBLL albumBLL)
        {
            Mapper.Initialize(cfg => cfg.CreateMap <TrackBLL, Track>());
            Track track = Mapper.Map <TrackBLL, Track>(trackBLL);

            if (genresBLL != null)
            {
                Mapper.Initialize(cfg => cfg.CreateMap <GenreBLL, Genre>());
                track.Genres = Mapper.Map <IEnumerable <GenreBLL>, IEnumerable <Genre> >(genresBLL).ToList();
            }

            if (albumBLL != null)
            {
                Mapper.Initialize(cfg => cfg.CreateMap <AlbumBLL, Album>());
                track.Album = Mapper.Map <AlbumBLL, Album>(albumBLL);
            }
            TracksDB.Tracks.Update(track);
        }
Ejemplo n.º 26
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (dgvAuthor.SelectedCells.Count > 0)
            {
                int selectedrowindex = dgvAuthor.SelectedCells[0].RowIndex;

                DataGridViewRow selectedRow = dgvAuthor.Rows[selectedrowindex];

                AuthorBLL authorBLL = new AuthorBLL(Convert.ToInt32(selectedRow.Cells["clmnId"].Value), txtAuthorName.Text, txtWorkPlace.Text);

                if (authorBLL.Name == "")
                {
                    MessageBox.Show("Author name is not null!", "Notice");
                    return;
                }
                AuthorDAL.updateAuthor(authorBLL);
                MessageBox.Show("Update success!", "Success");
                this.LoadDataToGridView();
            }
        }
Ejemplo n.º 27
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            BookModel book = BookBLL.FindBookById(id.Value);

            if (book == null)
            {
                return(HttpNotFound());
            }

            var bookViewModel = new BookDetailsViewModel(book);

            bookViewModel.BookID        = id.Value;
            bookViewModel.PublisherList = PublisherBLL.ListAll();
            bookViewModel.AuthorsList   = AuthorBLL.ListAll();

            return(View(bookViewModel));
        }
Ejemplo n.º 28
0
        public void CreateAlbum(AlbumBLL albumBLL, AuthorBLL authorBLL,
                                IEnumerable <GenreBLL> genresBLL, IEnumerable <TrackBLL> tracksBLL)
        {
            Mapper.Initialize(cfg => cfg.CreateMap <AlbumBLL, Album>());
            Album album = Mapper.Map <AlbumBLL, Album>(albumBLL);

            if (genresBLL != null)
            {
                Mapper.Initialize(cfg => cfg.CreateMap <GenreBLL, Genre>());
                album.Genres = Mapper.Map <IEnumerable <GenreBLL>, IEnumerable <Genre> >(genresBLL).ToList();
            }

            if (authorBLL != null)
            {
                Mapper.Initialize(cfg => cfg.CreateMap <AuthorBLL, Author>());
                album.Author = Mapper.Map <AuthorBLL, Author>(authorBLL);
            }
            if (tracksBLL != null)
            {
                Mapper.Initialize(cfg => cfg.CreateMap <TrackBLL, Track>());
                album.Tracks = Mapper.Map <IEnumerable <TrackBLL>, IEnumerable <Track> >(tracksBLL).ToList();
            }
        }
Ejemplo n.º 29
0
        public void UpdateAuthor(AuthorBLL authorBLL, IEnumerable <TrackBLL> tracksBLL, IEnumerable <AlbumBLL> albumsBLL, IEnumerable <GenreBLL> genresBLL)
        {
            Mapper.Initialize(cfg => cfg.CreateMap <AuthorBLL, Author>());
            Author author = Mapper.Map <AuthorBLL, Author>(authorBLL);

            if (genresBLL != null)
            {
                Mapper.Initialize(cfg => cfg.CreateMap <GenreBLL, Genre>());
                author.Genres = Mapper.Map <IEnumerable <GenreBLL>, IEnumerable <Genre> >(genresBLL).ToList();
            }

            if (albumsBLL != null)
            {
                Mapper.Initialize(cfg => cfg.CreateMap <AlbumBLL, Album>());
                author.Albums = Mapper.Map <IEnumerable <AlbumBLL>, IEnumerable <Album> >(albumsBLL).ToList();
            }
            if (tracksBLL != null)
            {
                Mapper.Initialize(cfg => cfg.CreateMap <TrackBLL, Track>());
                author.Tracks = Mapper.Map <IEnumerable <TrackBLL>, IEnumerable <Track> >(tracksBLL).ToList();
            }

            TracksDB.Authors.Update(author);
        }
Ejemplo n.º 30
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"));
        }