public void ContributorService_GetAll_CallsRepositoryAll()
        {
            #region Arrange

            #endregion

            #region Act

            _contributorService.All();

            #endregion

            #region Assert

            _mockContributorRepository.Verify(x => x.All(), Times.Once);

            #endregion
        }
Esempio n. 2
0
        public ActionResult AddContributor()
        {
            var vm = new AddCustomerContributorViewModel();

            if (_appUserContext.Current?.CurrentCustomer != null && _appUserContext.Current.CurrentCustomer.Id > 0)
            {
                vm.CustomerId   = _appUserContext.Current.CurrentCustomer.Id;
                vm.CustomerName = _appUserContext.Current.CurrentCustomer.CustomerName;

                vm.ReturnUrl = Url.Action("EditCustomer", "ServiceDecomposition", new { id = vm.CustomerId });

                var users = GetUsersInRole(UserRoles.Architect, true).ToList();

                if (users.Any())
                {
                    var customerContributors = _contributorService.All()
                                               .Where(c => c.CustomerId == vm.CustomerId)
                                               .Select(c => c.UserId)
                                               .ToList();

                    if (customerContributors.Any())
                    {
                        foreach (var contributor in customerContributors)
                        {
                            // Remove any users already contributing
                            users.RemoveAll(user => string.Equals(user.Id, contributor, StringComparison.InvariantCultureIgnoreCase));
                        }
                    }
                }

                vm.Users.AddRange(users.Select(s => new SelectListItem {
                    Text = s.UserName, Value = s.Id.ToString(CultureInfo.InvariantCulture)
                }).ToList());
            }

            return(View("AddCustomerContributor", vm));
        }