示例#1
0
        public IHttpActionResult Create(Faction faction)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            Context.Factions.Add(faction);
            Context.SaveChanges();

            return Ok();
        }
示例#2
0
        public IHttpActionResult Update(int id, Faction faction)
        {
            faction.Id = id;

            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            Context.Factions.Attach(faction);
            var entry = Context.Entry(faction);
            entry.State = EntityState.Modified;

            Context.SaveChanges();

            return Ok();
        }