Beispiel #1
0
 public HttpResponseMessage Delete(HttpRequestMessage request, int id)
 {
     return(CreateHttpResponse(request, () =>
     {
         HttpResponseMessage response = null;
         if (!ModelState.IsValid)
         {
             request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
         }
         else
         {
             var result = _appUser.Delete(id);
             if (result.IsSuccessStatusCode)
             {
                 var appGroup = result.Content.ReadAsAsync <int>().Result;
                 response = request.CreateResponse(result.StatusCode, appGroup);
             }
             else
             {
                 response = request.CreateErrorResponse(result.StatusCode, result.Content.ReadAsStringAsync().Result);
             }
         }
         return response;
     }));
 }
        public ActionResult DeleteUser(UpdateUserViewModel user)
        {
            var model = _userService.Find(user.Id);

            if (model != null)
            {
                _userService.Delete(model);
            }
            return(RedirectToAction("Index"));
        }
 public object Delete([FromBody] ApplicationUser model)
 {
     try
     {
         usersService.Delete(model);
         return(true);
     }
     catch (Exception ex)
     {
         return(errorLogService.InsertToErrorLog(ex, MethodBase.GetCurrentMethod().Name, Request.Headers["UserInfo"].ToString()));
     }
 }
Beispiel #4
0
        public async Task Delete(int Id)
        {
            var entityToDelete = (await ApplicationUserService.GetByFilter(x => x.Id == Id)).FirstOrDefault();

            if (entityToDelete != null)
            {
                await ApplicationUserService.Delete(entityToDelete);
            }
            else
            {
                Response.StatusCode = StatusCodes.Status404NotFound;
            }
        }
        public async Task ShoulDeleteApplicationUser()
        {
            userId = await applicationUserService.Add(new ApplicationUser { Username = "******", CredibilityScore = 69, });

            var entityToDelete = (await applicationUserService.GetByFilter(x => x.Username == "TestUser")).FirstOrDefault();

            await applicationUserService.Delete(entityToDelete);

            var result = (await applicationUserService.GetByFilter(x => x.Username == "TestUser")).FirstOrDefault();


            Assert.Null(result);
        }
        public ActionResult DeleteUser(string id)
        {
            try
            {
                var user = _applicationUserService.Find(x => x.Id.Equals(id)).Single();
                _applicationUserService.Delete(user);

                Alert("Usuário removido com sucesso!", Enum.NotificationType.success);
            }
            catch (Exception)
            {
                Alert("Ocorreu um erro! Informe o administrador do sistema.", Enum.NotificationType.error);
            }

            ModelState.Clear();
            UpdateUsers(_adminViewModel);

            return(View("User", _adminViewModel));
        }
        public IActionResult DeleteConfirmedAsync(int id)
        {
            var userAccountId = applicationUserService.GetAll().Where(p => p.Id == id && p.RecordStatus == Helpdesk.Model.Enums.RecordStatus.A).Select(p => p.AccountId).FirstOrDefault();

            var userIdentityId = userManager.Users.Where(p => p.IsEnabled).Where(p => p.AccountId == userAccountId).Select(p => p.Id).FirstOrDefault();

            var user = userManager.FindByIdAsync(userIdentityId).Result;

            if (user == null)
            {
                return(new NotFoundResult());
            }

            var demands = demandService.GetAllDemand().Where(p => p.ApplicationUserAccountId == user.AccountId && ((p.IsAccepted && p.IsDissolved && p.IsCompleted != true) || (p.IsAccepted && p.IsDissolved != true && p.IsCompleted != true))).ToList();

            if (demands.Count > 0)
            {
                return(UnprocessableEntity());
            }

            var userMapping = companyAgentMappingService.GetMappingsByUserId(id);

            user.IsEnabled = false;
            var result = userManager.UpdateAsync(user);

            applicationUserService.Delete(user.AccountId);

            foreach (var map in userMapping)
            {
                companyAgentMappingService.Delete(map.Id);
            }

            foreach (var demand in demands)
            {
                demandService.UpdateForDeletedUser(demand);
            }

            return(Ok());
        }
 public void Delete(ApplicationUser applicationUser)
 {
     _applicationUserService.Delete(applicationUser);
 }