Beispiel #1
0
        public IActionResult EditMaterial(int Id)
        {
            ProjectsViewModel projectsViewModel = new ProjectsViewModel();

            projectsViewModel.Repo      = _projectRepo;
            projectsViewModel.Projects  = _projectRepo.AllProjects;
            projectsViewModel.Designers = _designerRepo.AllDesigners;
            projectsViewModel.Materials = _materialRepo.AllMaterials;
            projectsViewModel.Project   = _projectRepo.GetProjectById(_materialRepo.GetMaterialById(Id).ProjectId);
            projectsViewModel.Material  = _materialRepo.GetMaterialById(Id);

            projectsViewModel.Designer = _designerRepo.GetDesignerById(projectsViewModel.Project.DesignerId);

            // if (projectsViewModel.Project == null || projectsViewModel.Designer == null)
            //     return NotFound();
            return(View(projectsViewModel));
        }
        public ActionResult <ProjectReadDto> GetProjectById(int id)
        {
            var project = _repository.GetProjectById(id);

            if (project != null)
            {
                return(Ok(_mapper.Map <ProjectReadDto>(project)));
            }
            return(NotFound());
        }
Beispiel #3
0
        public ActionResult <Project> GetUserProject()
        {
            var currentUserEmail = User.FindFirstValue(ClaimTypes.Email);
            var currentUser      = _userRepo.GetUserByEmail(currentUserEmail);

            if (currentUser == null)
            {
                return(null);
            }

            return(_projectRepo.GetProjectById(currentUser.ProjectId));
        }