Exemplo n.º 1
0
        public IHttpActionResult Create(NeedType needType)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            Context.NeedTypes.Add(needType);
            Context.SaveChanges();

            return Ok();
        }
Exemplo n.º 2
0
        public IHttpActionResult Update(int id, NeedType needType)
        {
            needType.Id = id;

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

            Context.NeedTypes.Attach(needType);
            var entry = Context.Entry(needType);
            entry.State = EntityState.Modified;

            Context.SaveChanges();

            return Ok();
        }