Example #1
0
        public IHttpActionResult Post(KingdomCreate kingdom)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var service = CreateKingdomService();

            if (!service.CreateKingdom(kingdom))
            {
                return(InternalServerError());
            }
            return(Ok());
        }
Example #2
0
        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);
            }
        }