Пример #1
0
        private List <DefectView> GetDefects(List <Customer> customers)
        {
            var defectObjs = new List <DefectView>();
            var defects    = new Defect().GetDefects();

            try
            {
                #region [Helpers]
                Func <int, string> fnGetPriorityName = (priorityID) =>
                {
                    Defect.DefectPriority priority = (Defect.DefectPriority)priorityID;
                    return(priority.ToString());
                };
                Func <int, string> fnGetCustomerName = (customerID) =>
                {
                    var customer = customers.Where(c => c.CustomerID == customerID).FirstOrDefault();
                    return(customer.CustomerName);
                };
                #endregion
                defects.ForEach(d => defectObjs.Add(new DefectView()
                {
                    DefectId    = d.DefectId,
                    Customer    = fnGetCustomerName(d.CustomerID),
                    Priority    = fnGetPriorityName(d.Priority),
                    CreatedDate = d.CreatedDate.ToString("MM/dd/yyyy"),
                    description = d.description
                }));
            }
            catch (Exception ex)
            {
            }
            return(defectObjs);
        }