/// <summary> /// Deletes user from database after selecting in combobox and click delete button. /// </summary> private void DeleteUserFromDatabaseButton(object sender, RoutedEventArgs e) { DeleteUser.DeleteClientFromDatabase(nameDataUserName.DisplayMemberPath, nameDataUserName.SelectedValue); ComboBoxSource.SetupItemsInComboBoxDisplay(nameDataUserName.ItemsSource = DisplayComboboxList.SetUpNameInComboBox(), nameDataUserName.DisplayMemberPath = "Name", nameDataUserName.SelectedValuePath = "ID"); }
public string DispatchCommand(string[] commandParameters) { var cmd = commandParameters[0].ToLower(); var cmdParams = commandParameters.Skip(1).ToArray(); string result = null; switch (cmd) { case "registeruser": result = RegisterUserCommand.Execute(cmdParams); break; case "addtown": result = AddTownCommand.Execute(cmdParams); break; case "modifyuser": result = ModifyUserCommand.Execute(cmdParams); break; case "deleteuser": result = DeleteUser.Execute(cmdParams); break; case "addtag": result = AddTagCommand.Execute(cmdParams); break; case "addfriend": result = AddFriendCommand.Execute(cmdParams); break; case "createalbum": result = CreateAlbumCommand.Execute(cmdParams); break; case "addtagto": result = AddTagToCommand.Execute(cmdParams); break; case "makefriends": result = AcceptFriendCommand.Execute(cmdParams); break; case "listfriends": result = PrintFriendsListCommand.Execute(cmdParams); break; case "sharealbum": result = ShareAlbumCommand.Execute(cmdParams); break; case "uploadpicture": result = UploadPictureCommand.Execute(cmdParams); break; default: throw new InvalidOperationException($"Command {cmd} not valid!"); } return(result); }
public void DeleteUser_Action_Fails() { // Arrange var userDto = TestHelper.UserDto(); GenericServiceResponse <bool> fakeResponse = null; mockClientServicesProvider.Setup(x => x.Logger).Returns(mockLogger.Object).Verifiable(); mockClientServicesProvider.Setup(x => x.UserService.DeleteUser(userDto)).Returns(fakeResponse).Verifiable(); var viewModel = new GenericViewModel(); var action = new DeleteUser <GenericViewModel>(mockClientServicesProvider.Object) { OnComplete = model => viewModel = model }; // Act var result = action.Invoke(userDto); // Assert Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(GenericViewModel)); Assert.IsNotNull(result.Notifications); Assert.IsInstanceOfType(result.Notifications, typeof(NotificationCollection)); Assert.IsTrue(result.Notifications.Count() == 1); Assert.IsTrue(result.HasErrors); Assert.IsNotNull(result.Success); Assert.IsInstanceOfType(result.Success, typeof(bool)); Assert.IsFalse(result.Success); }
private void DeleteUserClick(object sender, RoutedEventArgs e) { DeleteUser _deleteUser = new DeleteUser(); _deleteUser.Show(); this.Close(); }
private void Execute(DeleteUser command) { var user = AggregateStore.GetAggregate <User>(command.Id); user.Delete(); AggregateStore.Save(user); }
public void Any(DeleteUser request) { using (var db = DbFactory.OpenDbConnection()) { db.DeleteById <UserAuth>(request.Id); } }
public ActionResult <dynamic> DeleteUser([FromBody] DeleteUser user) { if (string.IsNullOrEmpty(user.username) || string.IsNullOrEmpty(user.selfusername)) { return(BadRequest()); } else { var admin = db.Users.FirstOrDefault(u => u.Username == user.selfusername && u.Status == AppConstants.Verified); if (admin?.Role == AppConstants.Admin) { var usr = db.Users.FirstOrDefault(u => u.Username == user.username); if (usr == null) { return(NotFound()); } usr.IsDeleted = true; var result = db.Users.Update(usr); db.SaveChanges(); return(NoContent()); } else { return(Unauthorized()); } } }
/// <summary> /// Запрос на удаление пользователя /// </summary> /// <param name="request">Запрос с данными</param> /// <returns>Результат запроса</returns> public object Post(DeleteUser request) { if (string.IsNullOrEmpty(request.FirstName) || string.IsNullOrEmpty(request.SecondName)) { return(new DeletedUserResponse { Response = "Вы не указали имя или фамилию студента!" }.ToJson()); } if (!UserMapper.Exist(request.FirstName, request.SecondName)) { return(new DeletedUserResponse { Response = $"Студента {request.FirstName} {request.SecondName} не существует" }.ToJson()); } UserMapper.DeleteUser(new User { FirstName = request.FirstName, SecondName = request.SecondName, }); return(new DeletedUserResponse() { Response = $"Студент {request.FirstName} {request.SecondName} был удалён." }.ToJson()); }
public async Task <IActionResult> DeleteNotif(int id) { var command = new DeleteUser(id); var result = await _mediatr.Send(command); return(result != null ? (IActionResult)Ok(new { Message = "success" }) : NotFound(new { Message = "not found" })); }
public async Task <ActionResult> Delete(DeleteUser model) { ApplicationUser user = await this.userManager.FindByIdAsync(model.Id); if (user != null) { IdentityResult deleteResult = await this.userManager.DeleteAsync(user); if (deleteResult.Succeeded) { return new ContentResult() { StatusCode = 200, ContentType = "application/json", Content = "true" } } ; else { string errorMessage = deleteResult.Errors.FirstOrDefault().Description; return(new ContentResult() { StatusCode = 500, ContentType = "application/json", Content = errorMessage }); } } return(new ContentResult() { StatusCode = 500, ContentType = "application/json", Content = "Invalid user id" }); }
public dynamic DeleteUser(DeleteUser user) { try { var request = mFactory.CreateRequest(); request.Resource = string.Format("user/delete?apikey={0}", ConfigVars.NewInstance.apikey); request.Method = Method.POST; request.AddHeader("Content-Type", "application/json"); request.RequestFormat = DataFormat.Json; request.AddBody(user); var blocker = new AutoResetEvent(false); IRestResponse httpResponse = null; var client = mFactory.CreateClient(); client.BaseUrl = new Uri("https://api.vsee.com/"); client.ExecuteAsync(request, response => { httpResponse = response; blocker.Set(); }); blocker.WaitOne(); if (httpResponse != null && (httpResponse.StatusCode == HttpStatusCode.OK || httpResponse.StatusCode == HttpStatusCode.Created)) { dynamic list = (new RestSharp.Deserializers.JsonDeserializer()).Deserialize <dynamic>(httpResponse); return(list); } } catch (Exception ex) { } return(null); }
private void fillUsersDelete() { deleteUsers.Clear(); DeleteUser.Items.Clear(); try { conn = new SqlConnection("server=10.100.100.25\\SPLAHOST;Database=graphs;Integrated Security=false;User ID=petpakn;Password=net123321!;"); conn.Open(); // Create SqlCommand to select pwd field from users table given supplied userName. cmd = new SqlCommand("Select uname from Users", conn); /// Intepolation or the F string. C# > 5.0 // Execute command and fetch pwd field into lookupPassword string. SqlDataReader sdr = cmd.ExecuteReader(); while (sdr.Read()) { deleteUsers.Add(sdr["uname"].ToString()); } cmd.Dispose(); conn.Close(); DeleteUser.DataSource = deleteUsers; DeleteUser.DataBind(); } catch (Exception ex) { } }
public async Task <IActionResult> DeleteAccount([FromBody] DeleteUser model) { var userToVerify = await _userManager.FindByEmailAsync(model.Email); if (userToVerify == null) { return(BadRequest()); } var callerId = GetCallerId(); if (callerId != userToVerify.Id) { return(BadRequest()); } var customerToRemove = _appDbContext.Customers.FirstOrDefault(customer => customer.IdentityId == userToVerify.Id); if (customerToRemove == null) { return(BadRequest()); } _appDbContext.Customers.Remove(customerToRemove); await _userManager.DeleteAsync(userToVerify); await _userCommonDataRepository.DeleteUserCommonData(userToVerify.Id); return(new OkObjectResult("Account Deleted")); }
public void Delete(DeleteUser c) { Apply(new UserDeleted { Id = c.Id, DeletedByUserId = c.DeletedByUserId, }); }
public IActionResult Delete(DeleteUser user) { if (_repo.Get(user.Id) == null) { return(BadRequest()); } return(Ok(_repo.Delete(user.ToDal()))); }
public async Task <IActionResult> Delete(Guid id) { var command = new DeleteUser(id); await SendAsync(command); return(NoContent()); }
public static DeleteUser CreateDeleteUser(IDatabaseContainer container) { DeleteUser deleteUser = new DeleteUser(container); deleteUser.targetDatabase = SystemeConstants.SystemDatabaseName; deleteUser.targetTableName = SystemeConstants.UsersTableName; return(deleteUser); }
public ActionResult Delete(DeleteUser user) { if (ModelState.IsValid && AccountDAO.DeleteUser(user.Id)) { return(RedirectToAction("Index", "Home")); } return(View()); }
private DeleteUser SetupCommand(string userId) { var command = new DeleteUser(_userValidatorMock.Object, _userControllerWrapperMock.Object); var args = new[] { "delete-user", userId }; command.Initialize(args, _portalSettings, null, -1); return(command); }
public async Task <IActionResult> Delete([FromBody] DeleteUser command) { await DispatchAsync(command); _logger.LogInfo($"User with user id: {command.Id} was removed."); return(NoContent()); }
private DeleteUserSuccess Handle(DeleteUser request) { var user = _repository.SingleOrDefault <Domain.User>(x => x.Id == request.Id); _repository.Remove(user); return(new DeleteUserSuccess(Context)); }
public async Task <IActionResult> DeleteUser(int userId) { var command = new DeleteUser { UserId = userId }; return(Ok(await _mediator.Send(command))); }
public static d.UserEntity ToDal(this DeleteUser user) { return(new d.UserEntity() { Id = user.Id, Reason = user.Reason, Disable_Until = user.Disable_Until }); }
protected void Button4_Click(object sender, EventArgs e) { DeleteUser deleteUser = new DeleteUser(); deleteUser.UID = int.Parse(TextBox3.Text); string res = client.Delete(deleteUser); lblmsg.Text = res.ToString(); }
protected void Button4_Click(object sender, EventArgs e) { DeleteUser d = new DeleteUser(); d.UID = int.Parse(txtuid.Text); string res = client.Delete(d); lblmsg.Text = res.ToString(); }
public void ShouldFailNotFound() { var command = new DeleteUser { Id = "asdwqedg" }; FluentActions.Invoking(() => SendAsync(command)).Should().Throw <NotFoundException>(); }
private void DelUser_Click(object sender, EventArgs e) { if (UserLoginDel.Text != null || UserLoginDel.Text != "") { DeleteUser deleteUser = new DeleteUser(); deleteUser.Del(UserLoginDel.Text); UpdateViews(); } }
protected void Button3_Click(object sender, EventArgs e) { int id = Convert.ToInt32(Request.Cookies["User"]["Logged"]); Response.Cookies["User"].Expires = DateTime.Now.AddDays(-1); db.deleteUser(id); DeleteUser.Hide(); Response.Redirect("index.aspx"); }
public void DeleteUser_NotDeleteableUser_NoticeInValidate() { IDatabaseContainer databaseContainer = ObjectConstructor.CreateDatabaseContainer(); string username = SystemeConstants.AdminUser; DeleteUser deleteUser = CreateDeleteUser(databaseContainer); deleteUser.SetTargetUserName(username); Assert.IsFalse(deleteUser.ValidateParameters()); }
public object Delete(DeleteUser request) { var entity = request.ConvertTo <User>(); return(InTransaction(db => { Logic.Remove(entity); return new CommonResponse(); })); }
public BLResponse<User> DeleteUser(DeleteUser user, BLRequest blRequest){ Client.Execute(proxy=>{ Users.Destroy(proxy, user.Id); }); var r = new BLResponse<User>(); if(IsCayita(blRequest)) r.Html= "record deleted"; return r; }
private void Initialiser() { delUser = new DeleteUser(); user = new List<DbUser>(); user.Add(new DbUser()); user[0].Username = "******"; //user[0].Password = "******"; //user[0].FirstName = "Thomas"; //user[0].LastName = "Shore"; //user[0].Email = "*****@*****.**"; //user[0].Location = "Manchester"; //user[0].TypeId = 3; //user.Add(new DbUser()); }
public async Task<IHttpActionResult> DeleteUserAsync(DeleteUser model) { if (model == null) { ModelState.AddModelError("", "Data required"); } if (ModelState.IsValid) { var result = await this.userManager.DeleteUserAsync(model.Subject); if (result.IsSuccess) { return Ok(); } foreach (var error in result.Errors) { ModelState.AddModelError("", error); } } return BadRequest(ModelState.GetErrorMessage()); }
private void btnDeleteUser_Click(object sender, EventArgs e) { DeleteUser objDelete = new DeleteUser(); objDelete.ShowDialog(); }
//Delete User need implementation public bool DeleteUser(List<DbUser> user) { DeleteUser deluser = new DeleteUser(); return deluser.GetCommand(user, 0); }
public void Delete(DeleteUser request) { AuthRepoProxy.Execute(db=>{ db.Delete<User>(q=>q.Id==request.Id); }); }
public HttpResponseMessage Delete(int userId) { //System.Threading.Thread.Sleep(3000); if (userId == 0) return Request.CreateResponse(HttpStatusCode.BadRequest); var user = _queryProcessor.Execute(new UserById(userId) { EagerLoad = new Expression<Func<User, object>>[] { x => x.Person } }); if (user != null) { var deleteUserCommand = new DeleteUser(User, user.RevisionId); _deleteUser.Handle(deleteUserCommand); } return Request.CreateResponse(HttpStatusCode.OK); }
public BLResponse<User> Any(DeleteUser request) { return Controller.DeleteUser(request, BLRequest); }
public List<DbJob> CheckAccManagerJobExists(string username) { DeleteUser delUser = new DeleteUser(); return delUser.CheckJobExists(username); }
public void When(DeleteUser c) { Update(c, ar => ar.Delete()); }