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

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

            return Ok();
        }
Esempio 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();
        }