Пример #1
0
        public async Task <IActionResult> AddResources(int id, SuitableProjectResourceViewModel resourcesToAdd)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var identityResourcesIds = resourcesToAdd.SuitableProjectResourceList.Where(x => x.IsChecked).Select(x => x.IdentityResource.Id).ToList();

            string user         = _userManager.GetUserName(User);
            var    notification = new Notification {
                Text = $"You were assigned to the project by {user}"
            };
            await _notificationRepository.Create(notification, identityResourcesIds);

            await _resourceService.AddResourcesAsync(await _projectRepository.GetOneAsync(id), identityResourcesIds);

            return(RedirectToAction("Details", new { id }));
        }