Example #1
0
        public async Task <IActionResult> Delete(UserDeleteGet UserToBeDeleted)
        {
            var CurrentUser = await _userManager.GetUserAsync(User);

            if (await _claimCheck.CheckClaim(CurrentUser, "ApplicationRight", this.ControllerContext.RouteData.Values["controller"].ToString() + "\\" + this.ControllerContext.RouteData.Values["action"].ToString()))
            {
                //                UserToBeDeleted.CreatorId = CurrentUser.Id;
                //var CheckString = await _classificationProvider.DeletePostCheck(Classification);
                //if (CheckString.Length == 0)
                //{

                var UserId = await _userProvider.usp_UserUpdatePostGetUserId(UserToBeDeleted.PersonId);

                var identityUser = await _userManager.FindByIdAsync(UserId);

                _userProvider.DeletePost(CurrentUser.Id, UserToBeDeleted.PersonId);
                _userManager.DeleteAsync(identityUser);

                return(Ok(UserToBeDeleted));

                //}
                return(BadRequest(new
                {
                    IsSuccess = false,
                    //Message = CheckString,
                }));
            }
            return(BadRequest(new
            {
                IsSuccess = false,
                Message = "No rights",
            }));
        }
Example #2
0
        public async Task <IActionResult> Delete(UserDeleteGet UserPerson)
        {
            var token = HttpContext.Session.GetString("Token"); if (token == null)
            {
                return(RedirectToAction("Login", "FrontAuth"));
            }
            await _client.PostProtectedAsync <UserDeleteGet>($"{_configuration["APIUrl"]}api/User/Delete", UserPerson, token);

            //return RedirectToAction("Index", new { id = UserMenu.UserMenuTemplateId });
            return(RedirectToAction("Index"));
        }
Example #3
0
        public async Task <IActionResult> Delete(int Id)
        {
            var CurrentUser = await _userManager.GetUserAsync(User);

            if (await _claimCheck.CheckClaim(CurrentUser, "ApplicationRight", this.ControllerContext.RouteData.Values["controller"].ToString() + "\\" + this.ControllerContext.RouteData.Values["action"].ToString()))
            {
                if (await _checkProvider.CheckIfRecordExists("Persons", "PersonID", Id) == 0)
                {
                    return(BadRequest(new
                    {
                        IsSuccess = false,
                        Message = "No record with this ID",
                    }));
                }
                var Person = await _userProvider.DeleteGetPerson(CurrentUser.Id, Id);

                var User = await _userProvider.DeleteGetUser(CurrentUser.Id, Id);

                var PersonUser = new UserDeleteGet();
                PersonUser.PersonId          = User.PersonId;
                PersonUser.UserName          = User.UserName;
                PersonUser.Email             = User.Email;
                PersonUser.SecurityLevelName = User.SecurityLevelName;
                PersonUser.Salutation        = Person.Salutation;
                PersonUser.FirstName         = Person.FirstName;
                PersonUser.MiddleName        = Person.MiddleName;
                PersonUser.LastName          = Person.LastName;
                PersonUser.PersonalTitle     = Person.PersonalTitle;
                PersonUser.Suffix            = Person.Suffix;
                PersonUser.NickName          = Person.NickName;
                PersonUser.FirstNameLocal    = Person.FirstNameLocal;
                PersonUser.MiddleNameLocal   = Person.MiddleNameLocal;
                PersonUser.GenderName        = Person.GenderName;
                PersonUser.BirthDate         = Person.BirthDate;
                PersonUser.OrganizationName  = Person.OrganizationName;
                PersonUser.CreatorName       = Person.CreatorName;
                PersonUser.CreatorId         = Person.CreatorId;
                PersonUser.CreatedDate       = Person.CreatedDate;
                PersonUser.ModifierName      = Person.ModifierName;
                PersonUser.ModifierId        = Person.ModifierId;
                PersonUser.ModifiedDate      = Person.ModifiedDate;


                return(Ok(PersonUser));
            }
            return(BadRequest(new
            {
                IsSuccess = false,
                Message = "No rights",
            }));
        }