/// <summary>
        /// Add to organization detail view model information about accounts.
        /// </summary>
        /// <param name="organizationDetail">Instance of organization detail for fill.</param>
        private void AddAccountsInfoToOrgDetailModel(OrganizationDetailViewModel organizationDetail)
        {
            int orgId = organizationDetail.Organization.Id;
            IEnumerable <OrgAccount> allOrgAccounts   = _unitOfWork.OrganizationAccountRepository.ReadAllOrgAccounts(orgId);
            IEnumerable <OrgAccount> filteredAccounts = allOrgAccounts
                                                        .Where(x => x.BankAccId != null && x.BankAccount.CardNumber != null)
                                                        .ToList();

            organizationDetail.OrgAccountsList = ConvertListOrgAccountToListOrgAccountDetailViewModel(filteredAccounts);
        }
        /// <summary>
        /// Add to organization detail view model information about admin.
        /// </summary>
        /// <param name="organizationDetail">Instance of organization detail for fill.</param>
        /// <param name="orgAdminId">Admin identifier.</param>
        private void AddAdminInfoToOrgDetailModel(OrganizationDetailViewModel organizationDetail, User orgAdmin)
        {
            PersonViewModel adminViewModel = new PersonViewModel();

            adminViewModel.FirstName = orgAdmin.FirstName;
            adminViewModel.LastName  = orgAdmin.LastName;
            if (orgAdmin.Phones.Count != 0)
            {
                adminViewModel.PhoneNumber = orgAdmin.Phones.FirstOrDefault().Number;
            }
            organizationDetail.Admin = adminViewModel;
        }
示例#3
0
        public async Task DeleteGetWhenMediatorReturnsAnOrganizationAViewOfThatOrganizationShouldBeShown()
        {
            CreateSut();

            var organizationModel = new OrganizationDetailViewModel();

            _mediator.Setup(x => x.SendAsync(It.Is <OrganizationDetailQueryAsync>(y => y.Id == Id))).ReturnsAsync(organizationModel);

            var result = (ViewResult)await _sut.Delete(Id);

            Assert.Same(organizationModel, result.ViewData.Model);
        }
        public async Task DetailsShouldReturnTheCorrectViewAndViewModelWhenOrganizationIsNotNull()
        {
            CreateSut();

            var model = new OrganizationDetailViewModel();

            _mediator.Setup(x => x.SendAsync(It.Is <OrganizationDetailQuery>(y => y.Id == Id))).ReturnsAsync(model);

            var result = (ViewResult)await _sut.Details(Id);

            Assert.IsType <ViewResult>(result);
            Assert.Same(model, result.ViewData.Model);
        }
        /// <summary>
        /// Get all detail about organization
        /// </summary>
        /// <param name="id">Id of organization</param>
        public OrganizationDetailViewModel GetOrganizationDetail(int id)
        {
            OrganizationDetailViewModel organizationDetail = new OrganizationDetailViewModel();

            try
            {
                OrganizationViewModel organization = GetOrganizationById(id);
                User orgAdmin = _unitOfWork.MembershipRepository.GetOrganizationAdmin(organization.Id);
                organizationDetail.Organization = organization;
                // if found admin of organization and he has phone
                if (orgAdmin != null && orgAdmin.Phones.Any())
                {
                    AddAdminInfoToOrgDetailModel(organizationDetail, orgAdmin);
                }
                AddAccountsInfoToOrgDetailModel(organizationDetail);
            }
            catch (NullReferenceException ex)
            {
                throw new DataAccessException(ErrorMessages.CantFindDataById, ex);
            }
            return(organizationDetail);
        }
 public OrganizationDetailPage(OrganizationModelView organization)
 {
     InitializeComponent();
     organizationDetailViewModel = new OrganizationDetailViewModel(organization, this, NavigationGlobalObject.Navigation);
 }