public IHttpActionResult Post(PublishingCompanyCreate model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (!_service.CreatePublishingCompany(model)) { return(InternalServerError()); } return(Ok("Publishing company created successfully!")); }
public bool CreatePublishingCompany(PublishingCompanyCreate model) { var entity = new PublishingCompany() { PublishingCompanyName = model.PublishingCompanyName, PublishingCompanyAddress = model.PublishingCompanyAddress }; using (var ctx = new ApplicationDbContext()) { ctx.PublishingCompanies.Add(entity); return(ctx.SaveChanges() == 1); } }