public bool CreateLeader(LeaderCreate model) { Leader leader = new Leader() { LeaderName = model.LeaderName, }; using (var ctx = new ApplicationDbContext()) { ctx.Leaders.Add(leader); return(ctx.SaveChanges() == 1); } }
public IHttpActionResult Post(LeaderCreate leader) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = new LeaderService(); if (!service.CreateLeader(leader)) { return(InternalServerError()); } return(Ok()); }