コード例 #1
0
        public bool UpdatePokemonType(PokemonTypeEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx.TypeDb
                    .Single(e => e.TypeID == e.TypeID);
                entity.TypeName = model.TypeName;


                return(ctx.SaveChanges() == 1);
            }
        }
コード例 #2
0
        public IHttpActionResult EditPokemonType(PokemonTypeEdit pokemonType)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreatePokemonTypeService();

            if (!service.UpdatePokemonType(pokemonType))
            {
                return(InternalServerError());
            }

            return(Ok());
        }