public IActionResult Edit(int id, string nameFilter, int pageNo)
        {
            var project = projectsRepo.Get(id);

            if (project == null)
            {
                return(IndexWithError(NOT_FOUND_ERROR, nameFilter, pageNo));
            }
            return(View(nameof(ProjectsController.Create), project));
        }
        public Project Get(string projectId, ClaimsPrincipal user)
        {
            Project project = projectsRepository.Get(projectId);

            project.ProjectMembers = projectMembersService.GetProjectMembersOfProject(projectId, userManager.GetUserId(user));
            if (project != null)
            {
                string currentUserId = userManager.GetUserId(user);
                project.ProjectMembers.Where(pm => pm.UserId == currentUserId)
                .ToList().ForEach(pm => pm.IsCurrentUser = true);
                project.ProjectActions = projectActionRepository.GetAll()
                                         .Where(x => x.ProjectId == project.Id).ToList();
            }
            return(project);
        }
Example #3
0
 public IList <Projects> Projects()
 {
     try
     {
         return(_projectsRepository.Get().ToList());
     }
     catch
     {
         return(new List <Projects>());
     }
 }
Example #4
0
        public async Task <Unit> Handle(DeleteProjectCommand request, CancellationToken cancellationToken)
        {
            var project = await _repository.Get(request.Id);

            if (project is null)
            {
                throw new EntityNotFound(nameof(project));
            }

            _repository.Delete(project);
            await _repository.SaveChanges();

            return(Unit.Value);
        }
        public async Task <IEnumerable <Project> > GetAll()
        {
            var projectEnitites = await _projectRepository.Get();

            List <Project> projects = new List <Project>();

            foreach (var projectEntity in projectEnitites)
            {
                var project = projectEntity.Adapt <Project>();
                project.Users = projectEntity.UserProjects.Select(u => u.User.Adapt <User>()).ToList();
                project.Owner = projectEntity.Owner.Adapt <User>();
                projects.Add(project);
            }
            return(projects);
        }
        public async Task <Unit> Handle(AddVacancyCommand request, CancellationToken cancellationToken)
        {
            var project = await _repository.Get(request.ProjectId);

            if (project is null)
            {
                throw new EntityNotFound(nameof(project));
            }

            project.AddVacancy(new Domain.Projects.Entities.Vacancy(request.Id, request.Name, request.Description, request.Status, request.ExpirationDate));

            _repository.Update(project);
            await _repository.SaveChanges();

            return(Unit.Value);
        }
Example #7
0
        public IActionResult Create(int projectId)
        {
            var project = projectsRepo.Get(projectId);

            if (project == null)
            {
                return(ProjectDetailsWithError(projectId, NOT_FOUND_ERROR));
            }
            var task = new Task()
            {
                ProjectId = project.ProjectId,
                Project   = project
            };

            return(View(task));
        }
Example #8
0
        public async Task <Unit> Handle(UpdateProjectCommand request, CancellationToken cancellationToken)
        {
            var project = await _repository.Get(request.Id);

            if (project is null)
            {
                throw new EntityNotFound(nameof(project));
            }

            project.ChangeName(request.Name);
            project.ChangeDescription(request.Description);
            project.SetRecruitingStatus(request.RecruitingStatus);
            project.UpdateProjectInformation(new ProjectInformation(request.Type, request.Category));

            _repository.Update(project);
            await _repository.SaveChanges();

            return(Unit.Value);
        }