Exemple #1
0
        /// <summary>
        /// we need to fetch partners separately, because the Queryfilters in Olma DbContext
        /// would not allow to get vouchers if Recipient,Shipper,SubShipper or Supplier
        /// are not in CustomerPartnerDirector of the actual user
        /// </summary>
        /// <param name="result"></param>
        private void Fetch(IPaginationResult <Voucher> result)
        {
            var vouchers    = result.Data.ToList();
            var recipients  = GetPartnerDict(vouchers.Select(c => c.RecipientId).Distinct());
            var suppliers   = GetPartnerDict(vouchers.Where(c => c.SupplierId != null).Select(c => (int)c.SupplierId).Distinct());
            var shippers    = GetPartnerDict(vouchers.Where(c => c.ShipperId != null).Select(c => (int)c.ShipperId).Distinct());
            var subShippers = GetPartnerDict(vouchers.Where(c => c.SubShipperId != null).Select(c => (int)c.SubShipperId).Distinct());

            var issuers         = GetIssuerDict(vouchers.Select(i => i.DivisionId).Distinct());
            var issuerCustomers = GetIssuerCustomerDict(vouchers.Select(i => i.DivisionId).Distinct());

            foreach (var voucher in vouchers)
            {
                voucher.IssuerCompanyName = issuerCustomers[voucher.DivisionId].Name;
                voucher.DivisionName      = issuers[voucher.DivisionId].Name;
                voucher.Recipient         = recipients[voucher.RecipientId]?.CompanyName;
                if (voucher.SupplierId != null)
                {
                    voucher.Supplier = suppliers[voucher.SupplierId.Value]?.CompanyName;
                }

                if (voucher.ShipperId != null)
                {
                    voucher.Shipper = shippers[voucher.ShipperId.Value]?.CompanyName;
                }

                if (voucher.SubShipperId != null)
                {
                    voucher.SubShipper = subShippers[voucher.SubShipperId.Value]?.CompanyName;
                }
            }
        }
        /// <summary>
        /// 現在のソート条件を、 <see cref="DataGrid"/> の各カラムのソート表示に反映する。
        /// </summary>
        private static void UpdateSortDirections(IPaginationResult result, DataGrid dataGrid)
        {
            // TODO: SortKey が重複していたら例外が投げられるので対処。
            var sortKeyFromColumn =
                result.PropertySorts.ToDictionary(ps => ps.Key);

            foreach (var column in dataGrid.Columns)
            {
                column.SortDirection =
                    sortKeyFromColumn
                    .GetValueOrNone(GetSortKey(column))
                    .Map(sk => sk.Direction)
                    .ToNullable();
            }
        }