public IHttpActionResult PutDeveloper(int id, Developer developer)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != developer.ID)
            {
                return BadRequest();
            }

            db.Entry(developer).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DeveloperExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
Exemplo n.º 2
0
        public void AddDeveloper(Developer developer)
        {
            var dc = new TrackerContext();
            dc.Developers.Add(developer);
            dc.SaveChanges();

            Clients.All.developerAdded(developer);
        }
        public IHttpActionResult PostDeveloper(Developer developer)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.Developers.Add(developer);
            db.SaveChanges();

            return CreatedAtRoute("DefaultApi", new { id = developer.ID }, developer);
        }