public async Task <IActionResult> Update(string id, [Bind("Author_id,Aithor_name")] Authors author) { if (id != author.Author_id) { return(NotFound()); } if (ModelState.IsValid) { try { await _context.UpdateAndSave(author); } catch (DbUpdateConcurrencyException) { if (!_context.CoachExists(author.Author_id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(author)); }
public void ExistsTest() { var fakeRepositoryMock = new Mock <IAuthorsRepository>(); fakeRepositoryMock.Setup(x => x.AuthorExists(It.IsAny <string>())).Returns(true); var coachService = new AuthorsService(fakeRepositoryMock.Object); bool result = coachService.CoachExists("1"); Assert.True(result); }