Пример #1
0
        public async Task <IActionResult> DelUser(string UserId)
        {
            var all_deployments_list = new List <Deployment>(_DeploymentService.Get());

            var deployments_z_userem_do_kasacji = new List <Deployment>();

            foreach (var document in all_deployments_list)
            {
                if (document.SchemaCreatedByUserId == UserId)
                {
                    deployments_z_userem_do_kasacji.Add(document);
                }
            }

            if (deployments_z_userem_do_kasacji.Count == 0)
            {
                var user_do_kasacji = _Userservice.Get(UserId);

                var user_list = new List <UserWithIdentity>();

                user_list.Add(user_do_kasacji);

                if (user_do_kasacji == null)
                {
                    return(NotFound());
                }

                var viewModel = new ShowAllUserViewModel()
                {
                    Users = user_list
                };

                _Userservice.Remove(user_do_kasacji.UserId);

                await _signInManager.SignOutAsync();

                return(View(viewModel));
            }
            else
            {
                return(RedirectToAction("NotDelUser", "User", new { UserId }));
            }
        }