/* * Transaction: Delete an user from the database * Returns true if the user exists in the database and * it was successfully deleted. */ public static bool DeleteUser(User delUser) { if (UserPersistence.getUserDB(delUser) == null) { return(false); } return(UserPersistence.DeleteUser(delUser)); }
/* * Transaction: Delete a book from the database * Returns true iff the book exists in the database and * it was successfully deleted. */ public static bool DeleteUser(User delUser) { // Verify that the user already exists User oldUser = UserPersistence.GetUser(delUser.UserId); // oldUser shouldnot be null, if this is a old user if (oldUser == null) { return(false); } return(UserPersistence.DeleteUser(delUser)); }
/// <summary> /// Delete an instance of user by its id. /// </summary> /// <param name="id"></param> /// <returns></returns> // DELETE: api/User/5 public HttpResponseMessage Delete(int id) { bool request = false; UserPersistence userPersistance = new UserPersistence(); request = userPersistance.DeleteUser(id); HttpResponseMessage response; if (request) { response = Request.CreateResponse(HttpStatusCode.NoContent); } else { response = Request.CreateResponse(HttpStatusCode.NotFound); } return(response); }
// DELETE: api/User/5 public HttpResponseMessage Delete(int id) { UserPersistence uP = new UserPersistence(); bool recordExisted = false; recordExisted = uP.DeleteUser(id); HttpResponseMessage response; if (recordExisted) { response = Request.CreateResponse(HttpStatusCode.NoContent); } else { response = Request.CreateResponse(HttpStatusCode.NotFound); } return(response); }
public string DeleteUser(int id) { try { if (Check()) { return(db.DeleteUser(id)); } } catch (UnCheckException ex) { throw ex; } catch (FindException) { throw new FindException(); } catch (GenericException ex) { throw ex; } return("No tienes permisos de administrador"); }
/// <summary> /// Delete a specific user by id /// </summary> /// <param name="UserId"></param> /// <returns></returns> // DELETE: api/User/5 public HttpResponseMessage Delete(long UserId) { bool recordExisted = false; User UserData = new User() { UserID = UserId }; recordExisted = UserPersistence.DeleteUser(UserId); HttpResponseMessage response; if (recordExisted) { // !Comment: return 402 -> record found with no content. response = Request.CreateResponse(HttpStatusCode.NoContent); } else { // !Comment: return 404 -> record not found. response = Request.CreateResponse(HttpStatusCode.NotFound); } return(response); }