コード例 #1
0
        public async Task SaveExperts(string projectId, IEnumerable <ExpertViewModel> experts)
        {
            foreach (var expertUser in experts.Where(x => !string.IsNullOrEmpty(x.UserId)))
            {
                var expert = await _expertRepository.GetAsync(expertUser.UserId);

                expert.ProjectId = projectId;
                expert.Priority  = 0;
                await _expertRepository.SaveAsync(expert);
            }
        }
コード例 #2
0
        public async Task <IActionResult> AddExpert(string email, string description, string projectId)
        {
            var profile = await _personalDataService.FindClientsByEmail(email);

            if (profile == null)
            {
                return(Json(new { Error = "User with this email does not exist!" }));
            }

            var expert = ExpertViewModel.Create(profile, projectId, description);

            try
            {
                await _projectExpertsRepository.SaveAsync(expert);
            }
            catch (Exception)
            {
                return(Json(new { Error = "This user is already an expert for this project!" }));
            }

            return(Json(expert));
        }