public static AccessChangeProjectViewModel ConvertForShare(Project project)
        {
            var projectViewModel = new AccessChangeProjectViewModel();

            projectViewModel.ProjectId    = project.Id;
            projectViewModel.ProjectTitle = project.Title;

            return(projectViewModel);
        }
Exemple #2
0
        public async Task <IActionResult> Share([Bind("ProjectId, Details, Role")] AccessChangeProjectViewModel shareProjectViewModel)
        {
            // TODO add bind

            // validate

            // Build user
            var remoteIpAddress = this.HttpContext?.Connection?.RemoteIpAddress?.ToString();
            var accessResult    = await _permissionService.GrantAccessAsync(
                shareProjectViewModel.ProjectId,
                shareProjectViewModel.Details,
                shareProjectViewModel.Role,
                remoteIpAddress,
                _projectsService);

            shareProjectViewModel.Result = accessResult.Success;

            if (string.IsNullOrWhiteSpace(accessResult.Message) == false)
            {
                shareProjectViewModel.Details = accessResult.Message;
            }

            return(View(shareProjectViewModel));
        }