public ActionResult DeleteUser(UserDelete deleteUser) { var loggedUser = (User)Session["User"]; if (loggedUser.Id == deleteUser.Id) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } //get user from db var user = db.Users.Find(deleteUser.Id); if (user != null) { //Delete the user from database db.Users.Remove(user); db.SaveChanges(); return(RedirectToAction("ManageUsers")); } else { //if there is no such user return bad request return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } }
/// <summary> /// 删除成员(并自动删除企业号成员) /// </summary> /// <param name="userId">成员Id</param> /// <returns></returns> public void DeleteMember(string userId) { try { UserDelete userDelete = new UserDelete(); userDelete.userid = userId; var result = userDelete.Send(); if (result.errcode == 0) { service.RemoveForm(userId); } else { WeChatUserRelationEntity weChatUserRelationEntity = new WeChatUserRelationEntity(); weChatUserRelationEntity.SyncState = result.errcode.ToString(); weChatUserRelationEntity.SyncLog = result.errmsg; service.SaveForm(userId, weChatUserRelationEntity); throw new Exception(result.errmsg); } } catch (Exception) { throw; } }
public async Task <object> Delete([FromBody] UserDelete requestDto) { _forwarderService.SetToken(GetTokenFromRequestHeader()); var data = await _forwarderService.ForwardRequest <object, object>(Request.Path.ToString() + "?id=" + requestDto.Id, requestDto.Id, HttpMethod.Delete); return(StatusCode((int)data.Item1, data.Item2)); }
public UserDeleteFixture(IADOperator adOperator) { _userDelete = new UserDelete(adOperator); UserPrincipalName = "*****@*****.**"; Settings = new UserSettings { LoginName = "admin", Password = "******", DomainName = "test" }; }
public IHttpActionResult RemoveUser(UserDelete delete) { UserService userService = CreateUserService(); var user = userService.DeleteUser(delete.Email); if (user) { return(Ok()); } return(BadRequest()); }
public IHttpActionResult Delete(UserDelete id) { var service = CreateUserService(); if (!service.DeleteUser(id)) { return(InternalServerError()); } return(Ok()); }
private UserController CreateUserControllerObject(UserDbContext context) { var mapper = Services.CreateAutoMapperObjectUsingUserProfile(); var repository = new UserRepository(context); var userFinder = new UserFind(repository, mapper); var userDelete = new UserDelete(repository, mapper); var userCreate = new UserCreate(repository, mapper); var userUpdate = new UserUpdate(repository, mapper); return(new UserController(userFinder, userCreate, userDelete, userUpdate)); }
public async Task Delete(data.ToDoDbContext db, UserDelete delete) { try { var userToDelete = await db.Users.FirstOrDefaultAsync(w => w.UserId == delete.UserId); db.Users.Remove(userToDelete); } catch (Exception e) { LogFactory.GetLogger().Log(LogLevel.Error, e); } }
public bool DeleteUser(UserDelete user) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Profiles .Single(e => e.OwnerId == user.OwnerId); ctx.Profiles.Remove(entity); return(ctx.SaveChanges() == 1); } }
public static void DeleteUser(this ICakeContext context, string userPrincipalName, UserSettings settings) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (settings == null) { throw new ArgumentNullException(nameof(settings)); } var userDelete = new UserDelete(new ADOperator(settings.LoginName, settings.Password, settings.DomainName)); userDelete.DeleteUser(userPrincipalName); }
// Delete Transaction Code public async Task Delete(UserDelete delete) { try { using (var db = new data.ToDoDbContext()) { await Delete(db, delete); await db.SaveChangesAsync(); } } catch (Exception e) { LogFactory.GetLogger().Log(LogLevel.Error, e); } }
public object Post(UserDelete userToDelete) { var documentStore = this.ResolveService <IDocumentStore>(); User loadedUser; var log = this.CreateLog( ActivityLog.LoggedActivities.Delete, userToDelete.Id); using (var session = documentStore.OpenSession()) { loadedUser = session.Load <User>(userToDelete.Id); loadedUser.Deleted = true; session.Store(log); session.SaveChanges(); } return(loadedUser); }
public async Task <ActionResult <bool> > DeleteUser(UserDelete userDelete) { var user = await _context.UserDatas.FirstOrDefaultAsync(x => x.ID == userDelete.ID); if (user == null) { return(false); } if (user.Password != userDelete.Password) { return(false); } try { if (user.Photo != null) { ImageDelete imgDelete = new ImageDelete(); imgDelete.ImageDeleteURL(user.Photo); } _context.UserDatas.Remove(user); var solForDelete = _context.PostSolutions.Where(x => x.UserType == 1 && x.UserID == user.ID); foreach (var item in solForDelete) { _context.PostSolutions.Remove(item); } await _context.SaveChangesAsync(); return(true); } catch (Exception e) { return(false); } }
public async Task <IActionResult> DeleteFriend([FromBody] UserDelete user) { if (user.UserFrom == null && user.UserTo == null) { ErrorViewModel.IsEmptyUser(); } var objFriend = await db.Users.FirstOrDefaultAsync(n => n.Login == user.UserTo); // Узнает id друга которого нужно удалить int idFriend = objFriend.Id; // Выбирает удаляемого друга UsersRelations deleteUser = await db.UsersRelations.FirstOrDefaultAsync(u => u.ToUserId == idFriend); // Удаляет друга if (deleteUser != null) { db.UsersRelations.Remove(deleteUser); await db.SaveChangesAsync(); return(Ok()); } return(ErrorViewModel.RemoveError()); }
public ActionResult DeleteUser(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } //get user from DB User users = db.Users.Find(id); if (users == null) { return(HttpNotFound()); } //bind the DB user with view model UserDelete deleteUser = new UserDelete(); deleteUser.Id = users.Id; deleteUser.Username = users.Username; deleteUser.FirstName = users.FirstName; deleteUser.LastName = users.LastName; return(View(deleteUser)); }
// Delete Transaction Code public async System.Threading.Tasks.Task Delete(UserDelete delete) { try { TableOperation retrieveOperation = TableOperation.Retrieve <data.User>("root", delete.UserId.ToString()); var userTable = await data.Utils.GetTable("User"); var result = await userTable.ExecuteAsync(retrieveOperation); if (result.Result != null) { var deleteEntity = (data.User)result.Result; TableOperation deleteOperation = TableOperation.Delete(deleteEntity); // Execute the operation. await userTable.ExecuteAsync(deleteOperation); } } catch (Exception e) { LogFactory.GetLogger().Log(LogLevel.Error, e); } }
public void UserDeleteButton() { UserDelete.Click(); }
public async Task <ActionResult <bool> > DeleteUser(UserDelete userDelete) { return(await _IUserDatasUI.DeleteUser(userDelete)); }
public Task <ActionResult <bool> > DeleteUser(UserDelete userDelete) { return(_IUserDatasBL.DeleteUser(userDelete)); }