/// <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); }
/// <summary> /// Christian Lopez /// Created: /// 2017/04/06 /// /// Returns a list of suppliers with their agreements by gettin a list of all suppliers and then finding the /// agreements associated with them. /// </summary> /// /// <remarks> /// Aaron Usher /// Updated: /// 2017/04/28 /// /// Standardized method. /// </remarks> /// /// <returns></returns> public static List <SupplierWithAgreements> RetrieveAllSuppliersWithAgreements() { var suppliersWithAgreements = new List <SupplierWithAgreements>(); try { var suppliers = RetrieveSuppliers(); foreach (var supplier in suppliers) { suppliersWithAgreements.Add(new SupplierWithAgreements() { ID = supplier.SupplierID, FarmAddress = supplier.FarmAddress, FarmCity = supplier.FarmCity, FarmName = supplier.FarmName, FarmState = supplier.FarmState, UserId = supplier.UserId, FarmTaxID = supplier.FarmTaxID, ApprovedBy = supplier.ApprovedBy, IsApproved = supplier.IsApproved, Active = supplier.Active, Agreements = AgreementAccessor.RetrieveAgreementsWithProductNameBySupplierId(supplier.SupplierID) }); } } catch (Exception) { throw; } return(suppliersWithAgreements); }