public void CreateAuthor(AuthorsDetailsInput authorInfo) { if (authorInfo.Name != null && authorInfo.Lastname != null) { var book = _regRepository.BooksDetails.Where(x => x.Id == authorInfo.BookId).FirstOrDefault(); if (book.AuthorsInfo == null) { AuthorsInfo author = new AuthorsInfo(); author.Name = authorInfo.Name; author.Lastname = authorInfo.Lastname; author.BirthCountry = authorInfo.BirthCountry; author.BirthDate = authorInfo.BirthDate; author.DeathDate = authorInfo.DeathDate; author.DateTime = DateTime.Now; book.AuthorsInfo = author; _regRepository.SaveChanges(); } } }
public IActionResult CreateAuthor(AuthorsDetailsInput authorInfo) { _authorsDetails.CreateAuthor(authorInfo); return(RedirectToAction("Index")); }