private void ButtonAdd_Click(object sender, RoutedEventArgs e) { //instantiate the object int genreId = ComboGenre.SelectedIndex + 1; try { Book b = new Book(0, TbAuthor.Text, TbTitle.Text, genreId, decimal.Parse(TbPrice.Text), DateTime.Parse(TbPubDate.Text), TbDescription.Text); db.AddBooks(b); } catch (ArgumentException ex) { MessageBox.Show("the values are out of range" + ex.StackTrace); } catch (FormatException ex) { MessageBox.Show("not A valid Format" + ex.StackTrace); } refreshBookList(); LvBooks.Items.Refresh(); //clear the field of textboxes TbAuthor.Clear(); TbTitle.Clear(); ComboGenre.SelectedValue = false; TbPubDate.Clear(); TbDescription.Clear(); TbPrice.Clear(); }
public async Task <bool> CreatetAuthor(AuthorDTO author) { if (author != null) { TbAuthor tbAuthor = _mapper.Map <TbAuthor>(author); var query = _mapper.Map <AuthorDTO>(await _repository.CreatetAuthor(tbAuthor)); return(query != null); } else { return(false); } }
public async Task <bool> CreateAuthor(TbAuthor author) { var query = await _context.Database.ExecuteSqlRawAsync(Resources.SpInsertAuthor, author.Name, author.LastName, author.Phone, author.Email, author.IdGender, author.NumberBooks, author.IdCity, author.IdState, author.IdCountry); return(query > 0); }
public async Task <bool> UpdateAuthor(AuthorDTO author) { TbAuthor tbAuthor = _mapper.Map <TbAuthor>(author); return(await _repository.UpdateAuthor(tbAuthor)); }