/// <summary>
        /// Christian Lopez
        ///
        /// Created:
        /// 2017/04/06
        ///
        /// Returns a list of agreements with the product names
        /// </summary>
        /// <param name="supplierId"></param>
        /// <returns></returns>
        public static List <AgreementWithProductName> RetrieveAgreementsWithProductNameBySupplierId(int supplierId)
        {
            List <AgreementWithProductName> agreementsWithNames = new List <AgreementWithProductName>();

            try
            {
                List <Agreement> agreementsBySupplier = retrieveAgreementsBySupplierId(supplierId);
                foreach (Agreement a in agreementsBySupplier)
                {
                    AgreementWithProductName newAgreement = new AgreementWithProductName()
                    {
                        ProductId     = a.ProductId,
                        AgreementId   = a.AgreementId,
                        Active        = a.Active,
                        ApprovedBy    = a.ApprovedBy,
                        IsApproved    = a.IsApproved,
                        DateSubmitted = a.DateSubmitted,
                        SupplierId    = a.SupplierId,
                        ProductName   = ProductAccessor.RetrieveProduct(a.ProductId).Name
                    };
                    agreementsWithNames.Add(newAgreement);
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(agreementsWithNames);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Aaron Usher
        /// Created:
        /// 2017/04/28
        ///
        /// Extension method to add agreements to a SupplierWthAgreements.
        /// </summary>
        /// <param name="supplierWithAgreements">The supplierWithAgreements to modify.</param>
        /// <returns>The same supplierWithAgreements, but with agreements!</returns>
        private static SupplierWithAgreements AddAgreements(this SupplierWithAgreements supplierWithAgreements)
        {
            try
            {
                List <Agreement> agreements = AgreementAccessor.retrieveAgreementsBySupplierId(supplierWithAgreements.SupplierID);
                List <AgreementWithProductName> agreementsWithProductName = new List <AgreementWithProductName>();
                foreach (var agreement in agreements)
                {
                    agreementsWithProductName.Add(new AgreementWithProductName()
                    {
                        Active        = agreement.Active,
                        AgreementId   = agreement.AgreementId,
                        ApprovedBy    = agreement.ApprovedBy,
                        DateSubmitted = agreement.DateSubmitted,
                        IsApproved    = agreement.IsApproved,
                        ProductId     = agreement.ProductId,
                        SupplierId    = agreement.ProductId,
                        ProductName   = ProductAccessor.RetrieveProduct(agreement.ProductId).Name
                    });
                }
                supplierWithAgreements.Agreements = agreementsWithProductName;
            }
            catch (Exception)
            {
                throw;
            }

            return(supplierWithAgreements);
        }