private async void finishAlbum_Click(object sender, EventArgs e)
        {
            if (this.ValidateChildren())
            {
                if (picboxAlbum.Image == null)
                {
                    errorProvider.SetError(picboxAlbum, "Image is required");
                    return;
                }
                else
                {
                    errorProvider.SetError(picboxAlbum, null);
                }


                byte[] ImageData = ImageHelperMethods.PrepareImgForDB(picboxAlbum.Image);

                AlbumInsertRequest obj = new AlbumInsertRequest()
                {
                    Name = txtTitle.Text, GenreId = (int)cmbGenre.SelectedValue, YearRelease = (int)cmbYear.SelectedValue, Image = ImageData, PerformerId = (int)cmbPerformer.SelectedValue, Description = txtAbout.Text
                };
                await _albumService.Insert <AlbumInsertRequest>(obj, "InsertAlbum");

                this.Close();
            }
        }
        public Album Insert(AlbumInsertRequest album)
        {
            var entity = _mapper.Map <Album>(album);

            _context.Album.Add(entity);
            _context.SaveChanges();

            return(_context.Album.Last());;
        }
        private async void btnUpdate_Click(object sender, EventArgs e)
        {
            byte[]             imgByte = ImageHelperMethods.PrepareImgForDB(picboxAlbum.Image);
            AlbumInsertRequest obj     = new AlbumInsertRequest
            {
                Name        = txtTitle.Text,
                YearRelease = Convert.ToInt32(cmbYear.SelectedValue),
                GenreId     = Convert.ToInt32(cmbGenre.SelectedValue),
                PerformerId = Convert.ToInt32(cmbPerformer.SelectedValue),
                Image       = imgByte
            };
            await _albumService.Update <AlbumInsertRequest>(_albumId, obj);

            this.Close();
        }
        public Album Update(int id, AlbumInsertRequest album)
        {
            var entity = _context.Album.Find(id);

            _context.Album.Attach(entity);
            _context.Album.Update(entity);

            entity.Name        = album.Name;
            entity.YearRelease = album.YearRelease;
            entity.GenreId     = album.GenreId;
            entity.Image       = album.Image;
            entity.PerformerId = album.PerformerId;

            _context.SaveChanges();

            return(entity);
        }
Exemple #5
0
 public ActionResult <Album> Update(int id, AlbumInsertRequest album)
 {
     return(_service.Update(id, album));
 }
Exemple #6
0
 public ActionResult <Album> Insert([FromBody] AlbumInsertRequest album)
 {
     return(_service.Insert(album));
 }
Exemple #7
0
        /* methods */

        public AddAlbumViewModel()
        {
            Title    = "Add album";
            AlbumReq = new AlbumInsertRequest();
        }