Exemplo n.º 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 }));
            }
        }
Exemplo n.º 2
0
        public IActionResult DelDatabase(string DatabaseId)
        {
            var all_deployments_list = new List <Deployment>(_DeploymentService.Get());

            var deployments_z_baza_do_kasacji = new List <Deployment>();

            foreach (var document in all_deployments_list)
            {
                if (document.TargetDbId == DatabaseId)
                {
                    deployments_z_baza_do_kasacji.Add(document);
                }
            }

            if (deployments_z_baza_do_kasacji.Count == 0)
            {
                var database_do_kasacji = _DatabaseService.Get(DatabaseId);

                var database_list = new List <Database>();

                database_list.Add(database_do_kasacji);

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

                var viewModel = new ShowAllDatabaseViewModel()
                {
                    Databases = database_list
                };

                _DatabaseService.Remove(database_do_kasacji.DatabaseId);

                return(View(viewModel));
            }
            else
            {
                return(RedirectToAction("NotDelDatabase", "Database", new { DatabaseId }));
            }
        }
Exemplo n.º 3
0
        public IActionResult DelProject(string ProjectId)
        {
            var all_deployments_list = new List <Deployment>(_DeploymentService.Get());

            var deployments_z_projektem_do_kasacji = new List <Deployment>();

            foreach (var document in all_deployments_list)
            {
                if (document.AttachedToProjectId == ProjectId)
                {
                    deployments_z_projektem_do_kasacji.Add(document);
                }
            }

            if (deployments_z_projektem_do_kasacji.Count == 0)
            {
                var project_do_kasacji = _ProjectService.Get(ProjectId);

                var project_list = new List <Project>();

                project_list.Add(project_do_kasacji);

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

                var viewModel = new ShowAllProjectViewModel()
                {
                    Projects = project_list
                };

                _ProjectService.Remove(project_do_kasacji.ProjectId);

                return(View(viewModel));
            }
            else
            {
                return(RedirectToAction("NotDelProject", "Project", new { ProjectId }));
            }
        }
        public IActionResult DelDeployment(string DeploymentId)
        {
            var document = _DeploymentService.Get(DeploymentId);

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

            var document_toDisplay = new DeploymentToDisplay(document, _ProjectService, _DatabaseService, _Userservice);

            _DeploymentService.Remove(document.DeploymentId);

            var deployment_list = new List <DeploymentToDisplay>();

            deployment_list.Add(document_toDisplay);

            var viewModel = new ShowAllDeploymentViewModel()
            {
                DeploymentToDisplay_List = deployment_list
            };

            return(View(viewModel));
        }
Exemplo n.º 5
0
        public async void Get_null_record()
        {
            var mock = new ServiceMockFacade <IDeploymentRepository>();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <string>())).Returns(Task.FromResult <Deployment>(null));
            var service = new DeploymentService(mock.LoggerMock.Object,
                                                mock.RepositoryMock.Object,
                                                mock.ModelValidatorMockFactory.DeploymentModelValidatorMock.Object,
                                                mock.BOLMapperMockFactory.BOLDeploymentMapperMock,
                                                mock.DALMapperMockFactory.DALDeploymentMapperMock,
                                                mock.BOLMapperMockFactory.BOLDeploymentRelatedMachineMapperMock,
                                                mock.DALMapperMockFactory.DALDeploymentRelatedMachineMapperMock);

            ApiDeploymentResponseModel response = await service.Get(default(string));

            response.Should().BeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <string>()));
        }