public IEnumerable<BillQuotationLight> GetBillQuotationByStatus(BILL_Status status) { var res = new List<BillQuotationLight>(); try { var list = billQuotationDAL.GetBillQuotation().Select(b => new BillQuotationLight(b)).Where(bq => bq.BillStatus.Status_Id == status.Status_Id); if (list != null && list.Count() > 0) res = list.ToList(); } catch (Exception ex) { throw new Exception(" BillQuotationBLL >> GetBillQuotationByStatus :" + ex.Message); } return res; }
public List<BillQuotationLight> SearchBillQuotation(string nomClient, string numFact, DateTime? dateDocument, BILL_Status status, int? MontantHTMin, int? MontantHTMax, bool? isBill) { var list = new List<BillQuotationLight>(); var noFilter = string.IsNullOrEmpty(nomClient) & string.IsNullOrEmpty(numFact) & dateDocument == null & status == null & MontantHTMin == null & MontantHTMax == null & isBill == null; if (noFilter) list = billQuotationBLL.GetBillQuotation().ToList(); /*** Filtre client ***/ if (nomClient != null) list.AddRange(billQuotationBLL.GetBillQuotation().Where(b => b.Company.name == nomClient).ToList()); /*** Filtre numero ***/ if (numFact != null) if (list.Count == 0) { var bill = billQuotationBLL.GetBillByNum(numFact); if (bill != null) list.Add(bill); } else list.Where(b => b.NBill == numFact); /*** Filtre status ***/ if (status != null) if (list.Count == 0) list.AddRange(billQuotationBLL.GetBillQuotationByStatus(status)); else list.Where(b => b.BillStatus.Status_Id == status.Status_Id); /*** Filtre date du document ***/ if (dateDocument != null) { if (list.Count == 0) list.AddRange(billQuotationBLL.GetBillQuotation().Where(b => b.DateBillQuotation.Date == dateDocument.Value.Date).ToList()); else list.Where(b => b.DateBillQuotation.Date == dateDocument.Value.Date); } /*** Filtre MontantHTMin ***/ if (MontantHTMin != null) if (list.Count == 0) list.AddRange(billQuotationBLL.GetBillQuotation().Where(b => b.AmountDF >= MontantHTMin).ToList()); else list.Where(b => b.AmountDF >= MontantHTMin); /*** Filtre MontantHTMax ***/ if (MontantHTMax != null) if (list.Count == 0) list.AddRange(billQuotationBLL.GetBillQuotation().Where(b => b.AmountDF <= MontantHTMax).ToList()); else list.Where(b => b.AmountDF <= MontantHTMax); ///*** Filtre MontantTTCMin ***/ //if (MontantTTCMin != null) // if (list.Count == 0) // list.AddRange(billQuotationBLL.GetBillQuotation().Where(b => b.AmountTTC > MontantTTCMin).ToList()); // else // list.Where(b => b.AmountTTC > MontantTTCMin); ///*** Filtre MontantTTCMax ***/ //if (MontantTTCMax != null) // if (list.Count == 0) // list.AddRange(billQuotationBLL.GetBillQuotation().Where(b => b.AmountTTC < MontantTTCMax).ToList()); // else // list.Where(b => b.AmountTTC < MontantTTCMax); /*** Filtre isbill ***/ if (isBill != null) if (Convert.ToBoolean(isBill)) if (list.Count == 0) list.AddRange(billQuotationBLL.GetBills().ToList()); else list.Where(b => b.NBill == null); else if (list.Count == 0) list.AddRange(billQuotationBLL.GetQuotations().ToList()); else list.Where(b => b.NBill != null); return list; }