public void CreateFromAPI(AuthorCreate authorCreate) { AuthorRepository authorRepository = new AuthorRepository(); authorRepository.Name = authorCreate.Name; this.authorStoreRepository.Create(authorRepository); }
public IHttpActionResult Post(AuthorCreate model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (!_service.CreateAuthor(model)) { return(InternalServerError()); } return(Ok("Author was added successfully!")); }
public bool CreateAuthor(AuthorCreate model) { var entity = new Author { Name = model.Name, BirthDate = model.BirthDate, }; using (var ctx = new ApplicationDbContext()) { ctx.Authors.Add(entity); return(ctx.SaveChanges() == 1); } }
public bool CreateAuthor(AuthorCreate model) { var authorToCreate = new Author() { Name = model.Name, CountryName = model.CountryName, }; using (var ctx = new ApplicationDbContext()) { ctx.Authors.Add(authorToCreate); return(ctx.SaveChanges() == 1); } }
public IHttpActionResult Post(AuthorCreate author) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateAuthorService(); if (!service.CreateAuthor(author)) { return(InternalServerError()); } return(Ok()); }
public bool CreateAuthor(AuthorCreate model) { var entity = new Author() { FirstName = model.FirstName, LastName = model.LastName, AuthorId = model.AuthorId, Description = model.Description }; using (var ctx = new ApplicationDbContext()) { ctx.Authors.Add(entity); return(ctx.SaveChanges() == 1); } }
public bool CreateAuthor(AuthorCreate model) { var entity = new Author() { CreatorId = _userId, AuthorName = model.AuthorName, Age = model.Age, Gender = model.Gender, CreatedUtc = DateTimeOffset.Now }; using (var ctx = new ApplicationDbContext()) { ctx.Authors.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult Create(AuthorCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateAuthorService(); if (service.CreateAuthor(model)) { TempData["SaveResult"] = "The author was created."; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Author could not be created."); return(View(model)); }
public bool CreateAuthor(AuthorCreate model) { var entity = new Author() { LastName = model.LastName, FirstName = model.FirstName, Patreon = model.Patreon, OfficialWebsite = model.OfficialWebsite, AmazonPage = model.AmazonPage, GoodreadsPage = model.GoodreadsPage, TwitterHandle = model.TwitterHandle, }; using (var ctx = new ApplicationDbContext()) { ctx.Authors.Add(entity); return(ctx.SaveChanges() == 1); } }
public void Store(AuthorCreate authorCreate) { this.authorApplication.CreateFromAPI(authorCreate); }