예제 #1
0
        public IHttpActionResult PutNote(int id, Note note)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #2
0
        public void SaveResponse(UserResponseModel userResponse)
        {
            try
            {
                using (YacEntities context = new YacEntities())
                {
                    var dbUserResponse = context.Set <UserResponse>();
                    dbUserResponse.Add(new UserResponse {
                        IdUser = userResponse.IdUser, DateResponse = userResponse.DateResponse, Response = userResponse.Response
                    });

                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
예제 #3
0
 public bool DeleteRegister(int idRegister)
 {
     try
     {
         using (YacEntities context = new YacEntities())
         {
             var register = new UserResponse {
                 Id = idRegister
             };
             context.UserResponse.Attach(register);
             context.UserResponse.Remove(register);
             context.SaveChanges();
         }
         return(true);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }