public IActionResult Create(AuthorViewModel vm) { Author a = Converter.AuthorViewModelToAuthor(vm); a.Id = Repo.CreateAuthor(a); vm.Id = a.Id; return(RedirectToAction("Detail", new { id = vm.Id })); }
private void CreateAuthorHelper(out AuthorForCreationDto model, out string authorId) { authorId = System.Guid.NewGuid().ToString(); string bookId = Guid.NewGuid().ToString(); model = ObjectMocks.GetAuthorForCreation(authorId, bookId); _auRepo.CreateAuthor(model, authorId); }
private void SaveButton_Click(object sender, EventArgs e) { if (_authors.GetAuthorList().Any(author => author.FirstName == FirstNameBox.Text) && _authors.GetAuthorList().Any(author => author.LastName == LastNameBox.Text)) { MessageBox.Show(@"Author already in database!", @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (string.IsNullOrWhiteSpace(FirstNameBox.Text) || string.IsNullOrWhiteSpace(LastNameBox.Text)) { MessageBox.Show(@"Inputs are empty!", @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { _authors.CreateAuthor(FirstNameBox.Text, LastNameBox.Text); Close(); } } }
public AuthorDto CreateAuthor(AuthorInputModel body) { return(_authorRepo.CreateAuthor(body)); }
public int CreateAuthor(AuthorInputModel author) { return(_authorRepository.CreateAuthor(author)); }
static void Main(string[] args) { connectionString = ConfigurationManager.ConnectionStrings["BooksDb"].ConnectionString; var authorRepo = new AuthorRepository(connectionString); Console.WriteLine("--- Get all authors with art in the name ---"); var arts = authorRepo.GetAuthorsByName("art"); PrintAuthors(arts); Console.WriteLine("--- Get George R.R. Martin by id ---"); var grrm = authorRepo.GetAuthorById(198); Console.WriteLine(grrm); Console.WriteLine("--- Insert new author ---"); Author author; string testName = "Test McTest"; try { author = authorRepo.CreateAuthor(testName); Console.WriteLine(author); } catch (ArgumentException ex) { Console.WriteLine(ex.Message); author = authorRepo.GetAuthorsByName(testName).Single(a => a.Name == testName); } Console.WriteLine("--- Insert author again ---"); try { author = authorRepo.CreateAuthor(testName); Console.WriteLine(author); } catch (ArgumentException ex) { Console.WriteLine(ex.Message); } Console.WriteLine("--- Delete author ---"); var deleted = authorRepo.DeleteAuthor(author); if (deleted) { Console.WriteLine($"Successfully deleted author {author.Id}"); } else { Console.WriteLine($"Error deleting author {author.Id}"); } Console.WriteLine("--- More delete author ---"); deleted = authorRepo.DeleteAuthor(author); if (deleted) { Console.WriteLine($"Successfully deleted author {author.Id}"); } else { Console.WriteLine($"Error deleting author {author.Id}"); } }
public async Task <Author> CreateAuthor(Author author) { return(await repository.CreateAuthor(author)); }
public AuthorDetailDto CreateAuthor(AuthorInputModel model) { return(_authorRepository.CreateAuthor(model)); }
public AuthorDto CreateAuthor(AuthorInputModel author) { return(_authorRepo.CreateAuthor(author)); }