Ejemplo n.º 1
0
        /*Printer*/
        public List <PrinterModels> GetSelectListPrinters(string StoreID, List <PrinterOnProductModels> ListPrinter)
        {
            List <PrinterModels> lstData   = _printerFactory.GetListPrinter(StoreID, null, CurrentUser.ListOrganizationId);
            List <PrinterModels> lstResult = new List <PrinterModels>();

            //if (lstData != null)
            //{
            //    foreach (PrinterModels item in lstData)
            //        lstResult.Add(new PrinterModels
            //        {
            //            PrinterName = item.PrinterName,// + " [" + item.StoreName + "]",
            //            Id = item.Id,
            //            Status = 9
            //        });
            //}
            //lstResult.ForEach(x =>
            //{
            //    if (ListPrinter.Count != 0)
            //    {
            //        x.Status = ListPrinter.Where(z => z.PrinterID.Equals(x.Id)).FirstOrDefault() != null ? (byte)Commons.EStatus.Actived : (byte)Commons.EStatus.Deleted;
            //    }
            //});

            if (lstData != null && lstData.Any())
            {
                if (ListPrinter == null)
                {
                    ListPrinter = new List <PrinterOnProductModels>();
                }
                var  printer      = new PrinterOnProductModels();
                bool isMapProduct = false;
                int  status       = (int)Commons.EStatus.Deleted;
                foreach (PrinterModels item in lstData)
                {
                    isMapProduct = false;
                    status       = (int)Commons.EStatus.Deleted;
                    printer      = ListPrinter.Where(w => w.PrinterID == item.Id).FirstOrDefault();
                    if (printer != null)
                    {
                        isMapProduct = true;
                        status       = printer.IsActive ? (int)Commons.EStatus.Actived : (int)Commons.EStatus.Deleted;
                    }
                    lstResult.Add(new PrinterModels()
                    {
                        PrinterName  = item.PrinterName,// + " [" + item.StoreName + "]",
                        Id           = item.Id,
                        Status       = status,
                        IsMapProduct = isMapProduct
                    });
                }
            }
            lstResult = lstResult.OrderBy(o => o.PrinterName).ToList();
            return(lstResult);
        }