Example #1
0
        public IHttpActionResult PutIdea(int id, Idea idea)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != idea.Id)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #2
0
 public void Update(Record record)
 {
     using (IdeasContext context = new IdeasContext())
     {
         record.UpdateDate           = DateTime.Now;
         context.Entry(record).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
        public IHttpActionResult PutIdea(int id, Idea idea)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != idea.Id)
            {
                return(BadRequest());
            }

            //Se asigna este operadopr para evitar que otros usuarios
            //puedan modificar los post de otros usuarios

            //obtenemos usuario
            var userId = User.Identity.GetUserId();

            if (userId != idea.UserId)
            {
                return(StatusCode(HttpStatusCode.Conflict));
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #4
0
 public void Update(User user)
 {
     db.Entry(user).State = EntityState.Modified;
 }
Example #5
0
 public void Update(Idea idea)
 {
     db.Entry(idea).State = EntityState.Modified;
 }
 public void Update(Role role)
 {
     db.Entry(role).State = EntityState.Modified;
 }