public GetAuthorDTO GetAuthorById(int id) { Author author = _Repository.GetById(id); GetAuthorDTO authorDTO = null; if (id != 0) { authorDTO = new GetAuthorDTO() { id = author.id, name = author.name, dob = author.dob, qualification = author.qualification, profession = author.profession }; } return(authorDTO); }
public IList <GetAuthorDTO> GetAuthors() { IList <Author> authors = _Repository.Table.ToList <Author>(); IList <GetAuthorDTO> authorList = new List <GetAuthorDTO>(); foreach (var author in authors) { GetAuthorDTO authorDTO = new GetAuthorDTO() { id = author.id, name = author.name, dob = author.dob, qualification = author.qualification, profession = author.profession }; authorList.Add(authorDTO); } return(authorList); }
// GET: Authors/Delete/5 public ActionResult Delete(int id) { GetAuthorDTO author = _authorService.GetAuthorById(id); return(View(author)); }