public IHttpActionResult Post(KingdomCreate kingdom) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateKingdomService(); if (!service.CreateKingdom(kingdom)) { return(InternalServerError()); } return(Ok()); }
public bool CreateKingdom(KingdomCreate model) { var entity = new Data.Kingdom() { OwnerId = _kingdomId, Name = model.Name, Description = model.Description, RegionId = model.RegionId }; using (var ctx = new ApplicationDbContext()) { ctx.Kingdoms.Add(entity); return(ctx.SaveChanges() == 1); } }