public bool Create(DevCreateModel model) { // Object Initialization Syntax var entity = new DevData() { Name = model.Name, HireDate = model.HireDate, ProficiencyLevel = model.ProficiencyLevel }; using (var ctx = new ApplicationDbContext()) { ctx.Developers.Add(entity); return(ctx.SaveChanges() == 1); } }
// endpoint public IHttpActionResult Create(DevCreateModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } //Instantiate the specific dev service var service = LocalDevService(); //Call the appropriate method //passing in the appropiate model if (!service.Create(model)) { return(InternalServerError()); } return(Ok(model)); }