示例#1
0
        public bool CreateMove(MoveCreate model)
        {
            var entity =
                new Move()
            {
                MoveName   = model.MoveName,
                Damage     = model.Damage,
                CreatedUtc = DateTimeOffset.Now
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.MoveDb.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
示例#2
0
        public IHttpActionResult Post(MoveCreate move)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateMoveService();

            if (!service.CreateMove(move))
            {
                return(InternalServerError());
            }

            return(Ok());
        }
示例#3
0
        public bool CreateMove(MoveCreate model)
        {
            var entity =
                new Move()
            {
                MoveName    = model.MoveName,
                Accuracy    = model.Accuracy,
                Power       = model.Power,
                Description = model.Description,
                TypeID      = model.MoveTypeID
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.MoveDb.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }