public IActionResult Post([FromBody] AuthorModel newAuthor) { try { _authorServices.Add(newAuthor.ToDomainModel()); } catch (System.Exception ex) { ModelState.AddModelError("addAuthor", ex.GetBaseException().Message); } return(CreatedAtAction("Get", new { Id = newAuthor.Id }, newAuthor)); }
public ActionResult Create([Bind(Include = "LastName,FirstName,DateOfBirth,DateOfDeath,AboutAuthor,UploadedFile")] AuthorDTO model) { if (ModelState.IsValid) { var author = DependencyResolver.Current.GetService <IAuthor>(); //var author = new Author(); Mapper.Map(model, author); if (model.UploadedFile != null) { author.FileModelId = _fileServices.CheckDbAndUploadeFile(model.UploadedFile); } _services.Add(author); return(RedirectToAction("Index")); } return(View(model)); }
public Author Add(Author newAuthor) { return(_authorServices.Add(newAuthor)); }