/// <summary> /// Gets the consignment fees for one entirty ID: Consignor, Consignment or Lot /// </summary> /// <param name="oneID">ID of entiry to get fees for from AUFees</param> /// <param name="entityType">Type (table name) of entity to get fees for: AUConsignor, AUConsignment, AULot</param> /// <returns>A single AUFeesRecord for the entity</returns> public virtual List<AUCombFinderFees> GetFinderFeesForOneId(int oneID, string entityType) { var allfinderfees = new List<AUCombFinderFees>(); var query = _finderfeesRepo.Table; query = query.Where(c => oneID == c.AUEntityID); query = query.Where(c => c.AUEntityType.Contains(entityType)); //var consignorfees = query.FirstOrDefault(); var consignorfees = query.ToList(); if (consignorfees.Count > 0) { foreach (AUFinderFeesRecord f in consignorfees) { var finderfees = new AUCombFinderFees(); finderfees.AUEntityID = f.AUEntityID; finderfees.AUEntityType = f.AUEntityType; finderfees.AUFinderFeesID = f.AUFinderFeesID; finderfees.CustomerID = f.CustomerID; finderfees.DisplayOrder = f.DisplayOrder; finderfees.FinderFeeAmt = f.FinderFeeAmt; finderfees.FinderFeePct = f.FinderFeePct; var customer = _customerRepo.GetById(f.CustomerID); if (customer != null) { finderfees.Email = customer.Email; finderfees.FullName = customer.GetFullName(); } allfinderfees.Add(finderfees); } } return allfinderfees; }
/// <summary> /// Gets finder fees for a lot - usually inherited from consignment but can be overridden /// </summary> /// <param name="lotID">ID of AUIncrement to delete</param> public virtual List<AUCombFinderFees> GetFinderFeesHierarchyForLotId(int lotID) { var allfinderfees = new List<AUCombFinderFees>(); var query = _finderfeesRepo.Table; query = query.Where(c => lotID == c.AUEntityID); query = query.Where(c => c.AUEntityType.Contains("AULot")); var lotfinderfees = query.ToList(); if (lotfinderfees.Count > 0) { foreach (AUFinderFeesRecord lotfinderfee in lotfinderfees) { var finderfees = new AUCombFinderFees(); finderfees.AUEntityID = lotfinderfee.AUEntityID; finderfees.AUEntityType = lotfinderfee.AUEntityType; finderfees.AUFinderFeesID = lotfinderfee.AUFinderFeesID; finderfees.CustomerID = lotfinderfee.CustomerID; finderfees.DisplayOrder = lotfinderfee.DisplayOrder; finderfees.FinderFeeAmt = lotfinderfee.FinderFeeAmt; finderfees.FinderFeePct = lotfinderfee.FinderFeePct; var customer = _customerRepo.GetById(lotfinderfee.CustomerID); if (customer != null) { finderfees.Email = customer.Email; finderfees.FullName = customer.GetFullName(); } allfinderfees.Add(finderfees); } } //get the aulot to blow out the consignments - if any consignment has an explicit specified finder fee, inherit that fee to the lot var lot = _lotRepo.GetById(lotID); if (lot != null) { foreach (var co in lot.AUConsignmentRecords) { var consignmentfees = GetFinderFeesForOneId(co.AUConsignmentID, "AUConsignment"); if (consignmentfees.Count > 0) //A lot should never exist without a consignment { //allfinderfees.AddRange(consignmentfees); foreach (AUCombFinderFees c in consignmentfees) { allfinderfees.Add(c); //inherit the lot fees they don't exist (override) and if a consignment finder fee exists if (lotfinderfees == null) { var inhlotfees = new AUCombFinderFees(); inhlotfees.AUEntityID = lotID; inhlotfees.AUEntityType = "AULot(I)"; inhlotfees.AUFinderFeesID = 0; inhlotfees.DisplayOrder = 2; inhlotfees.CustomerID = c.CustomerID; inhlotfees.Email = c.Email; inhlotfees.FullName = c.FullName; inhlotfees.FinderFeeAmt = c.FinderFeeAmt; inhlotfees.FinderFeePct = c.FinderFeePct; allfinderfees.Add(inhlotfees); } } } } } return allfinderfees; }