Esempio n. 1
0
        public IActionResult Index(int idProject)
        {
            var idUser = _userTable.GetUserId(HttpContext.User.Identity.Name);

            if (_projectTable.UserCanViewProject(idUser, idProject))
            {
                var project = _projectTable.GetProjectById(idProject);
                var model   = new ProjectViewModel()
                {
                    Project                 = project,
                    UserProjects            = _projectTable.GetUserProjectsByProjectId(idProject),
                    Tasks                   = _taskTable.GetTasksByProjectId(idProject).OrderByDescending(t => t.Created),
                    IdSignedUser            = idUser,
                    IdRoleSignedUserProject = _projectTable.GetRoleOfUser(idUser, idProject),
                    UsersOutOfProject       = new List <SelectListItem>(),
                    UserInProject           = new List <SelectListItem>(),
                    Priority                = new List <SelectListItem>(),
                    IdService               = _serviceOrderTable.GetInUseServiceIdByTenantId(_tenantTable.GetTenantId(HttpContext.Items["domain"] as string)),
                    SettingsColoring        = _userTable.GetSettingsbyUserId(idUser).Coloring == "1" ? true : false,
                    PageTitle               = project.Name,
                    PageDescription         = project.Description,
                    TaskForm                = new TaskForm()
                };
                foreach (var user in _userTable.GetUsersOutOfProjectByProjectId(idProject))
                {
                    var text = user.FirstName + " " + user.Surname + " - " + user.Email;
                    model.UsersOutOfProject.Add(new SelectListItem {
                        Text = text, Value = user.Id.ToString()
                    });
                }
                foreach (var user in _userTable.GetUsersInProjectByProjectId(idProject))
                {
                    var text = user.FirstName + " " + user.Surname + " - " + user.Email;
                    model.UserInProject.Add(new SelectListItem {
                        Text = text, Value = user.Id.ToString()
                    });
                }
                foreach (string name in Enum.GetNames(typeof(Priority)))
                {
                    model.Priority.Add(new SelectListItem {
                        Text = name, Value = name
                    });
                }
                return(View(model));
            }
            return(RedirectToAction("Index", "HomePage"));
        }