public void DeleteAuthor() { string authorId; CreateAuthorHelper(out _, out authorId); _auRepo.DeleteAuthor(authorId); var getAuthor = _auRepo.GetAuthor(authorId); Assert.Null(getAuthor); }
public IActionResult Delete(int id) { AuthorRepository authorRepository = new AuthorRepository(appDbContext); authorRepository.DeleteAuthor(id); return(Ok(id)); }
private void DeleteButton_Click(object sender, EventArgs e) { if (AuthorsListBox.CheckedItems.Any()) { var flag = true; foreach (var book in _books.GetBooksList()) { if (AuthorsListBox.CheckedItems[0].ToString() == $"{book.Author.FirstName} {book.Author.LastName}") { flag = false; } } if (!flag) { MessageBox.Show(@"Author is assigned to a book!", @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { var result = MessageBox.Show(@"Are you sure?", @"Confirm delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { _authors.DeleteAuthor(AuthorsListBox.CheckedItems[0].ToString()); LoadForm(); LoadBooks(); } } } }
//// GET: Delete Book Details //[HttpPost] public ActionResult DeleteAuthor(int id) { var profileData = Session["UserProfile"] as UserSession; if (profileData == null) { return(RedirectToAction("Index", "Home")); } try { AuthorRepository AuthorRepo = new AuthorRepository(); if (AuthorRepo.DeleteAuthor(id)) { ViewBag.AlertMsg = "Book details deleted successfully"; } var logModel = new LogModel { UserId = profileData.UserID, TableName = "Author", Activity = "Deleted Author", LogDate = DateTime.Now }; var logRepository = new logRepository(); logRepository.AddLog(logModel); return(RedirectToAction("GetAllAuthorDetails")); } catch { return(RedirectToAction("GetAllAuthorDetails")); } }
// DELETE: api/Author/5 public HttpResponseMessage Delete(int id) { AuthorRepository.DeleteAuthor(id); var response = Request.CreateResponse(HttpStatusCode.OK, id); return(response); }
public static void DelteAuthor_4_NotNull() { int authorID = 4; var rezult = _authorRepository.DeleteAuthor(authorID); Assert.NotNull(rezult); }
public ActionResult <string> Delete(int id) { if (_repo.DeleteAuthor(id)) { return(Ok("Successfully deleted!")); } return(BadRequest("Unable to delete!")); }
public ActionResult DeleteConfirmed(int id) { db1.DeleteAuthor(id); //Author author = db.Authors.Find(id); //db.Authors.Remove(author); //db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Delete(long id) { var success = AuthorRepository.DeleteAuthor(id); if (success) { return(Ok()); } return(NotFound()); }
public static void DelteAuthor_4_NotNull() { int authorID = 4; _mock.Setup(p => p.DeleteAuthor(authorID)).Returns(authorRepository.DeleteAuthor(authorID)); var rezult = _mock.Object.DeleteAuthor(authorID); Assert.NotNull(rezult); }
public async Task <IActionResult> DeleteConfirmed(int id) { var author = await repository.GetAuthorByIdAsync(id); if (author != null) { repository.DeleteAuthor(id); await repository.SaveAsync(); } return(RedirectToAction(nameof(Index))); }
public IHttpActionResult DeleteScratch(int id) { Scratch scratch = _authorRepo.GetSingleAuthor(id); if (scratch == null) { return(NotFound()); } _authorRepo.DeleteAuthor(id); return(Ok(scratch.FirstName + " Deleted")); }
static void Main(string[] args) { var authorRepository = new AuthorRepository(); while (true) { Console.WriteLine("Pick an option\n 1) View songs by an author\n 2) Add an author\n 3) Remove an author"); int optionChosen = int.Parse(Console.ReadLine()); if (optionChosen == 1) { Console.WriteLine("Name: "); string name = Console.ReadLine(); authorRepository.GetAuthorByName(name).Songs.ToList().ForEach(x => Console.WriteLine(x.NameAndDuration)); } else if (optionChosen == 2) { string name; //does not work if name is defined inside 'do' block do { Console.WriteLine("Name: "); name = Console.ReadLine(); }while (authorRepository.GetAuthorByName(name) != null); Console.WriteLine("Password: "******"Name: "); name = Console.ReadLine(); }while (authorRepository.GetAuthorByName(name) == null); //please note: != changed to == Console.WriteLine("Password: "); string password = Console.ReadLine(); authorRepository.DeleteAuthor(name, password); } } }
// GET: Authors/Delete/5 public async Task <IActionResult> Delete(int?id) { if (id == null) { return(NotFound()); } var author = await AuthorRepository.DeleteAuthor(id); if (author == null) { return(NotFound()); } return(View(author)); }
public void DeleteAuthorById(int id) { //var entity = _newsRepository.GetNewsById(id); //if (entity == null) { throw new Exception($"NewsItem with id {id} was not found."); } _authorRepository.DeleteAuthor(id); }
public static bool DeleteAuthor(int authorID) { return(AuthorRepository.DeleteAuthor(authorID)); }
public IActionResult Delete(int id) { Repo.DeleteAuthor(id); return(RedirectToAction("Index")); }
public async Task DeleteAuthor(Author author) { await AuthorRepository.DeleteAuthor(author); }
public static void DeleteAuthor(author a) { AuthorRepository.DeleteAuthor(a); }
public void DeleteAuthor(int id) { _authorRepository.DeleteAuthor(id); }
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 ActionResult DeleteAuthor(int id) { bool IsRemoved = authorRepository.DeleteAuthor(id); return(Json(IsRemoved, JsonRequestBehavior.AllowGet)); }