public async Task CreateAsync(Project project) { _productValidator.ValidateAndThrow(project); var entity = _mapper.Map <Domain.Entities.Project>(project); await _cosmosToggleDataContext.ProjectRepository.AddAsync(entity, entity.Id); var user = await _securityContext.GetUserAsync(); //TODO: using Polly await _userAppService.AddProjectAsync(user.Id, project.Id); }
public async Task <bool> UserHasAuthProjectAsync(string projectId) { var user = await _securityContext.GetUserAsync(); var friendlyMessage = $"User unauthorized in project '{projectId}'."; if (user == null) { await _notificationContext.AddAsync(HttpStatusCode.Unauthorized, $"User not found in claims", friendlyMessage); return(false); } if (user.Projects == null || !user.Projects.Contains(projectId)) { await _notificationContext.AddAsync(HttpStatusCode.Unauthorized, $"User projects list not contains '{projectId}'", friendlyMessage); return(false); } return(true); }