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

            Context.Needs.Add(need);
            Context.SaveChanges();

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

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

            Context.Needs.Attach(need);
            var entry = Context.Entry(need);
            entry.State = EntityState.Modified;

            Context.SaveChanges();

            return Ok();
        }