public static HCO GetLatestHCOInfo(string hcoId, IEnumerable <Sales> sales) { var first_hco = (from s in sales where s.HCOId == hcoId orderby s.Month descending select s).FirstOrDefault(); HCO h = new HCO(); if (first_hco != null) { h.ID = hcoId; h.Potential = first_hco.Potential; h.Level = first_hco.Level; } return(h); }
public static HCO GetHCOInfobyQuarter(string hcoId, IEnumerable <Sales> sales, string quarterString) { var first_hco = (from s in sales where DateTimeUtility.GetQuarterString(s.Month) == quarterString && s.HCOId == hcoId orderby s.Month descending select s).FirstOrDefault(); HCO h = new HCO(); if (first_hco != null) { h.ID = hcoId; h.Potential = first_hco.Potential; h.Level = first_hco.Level; } else { h = GetLatestHCOInfo(hcoId, sales); } return(h); }