Example #1
0
        //private void CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        //{
        //Notify("IncludeFolders");
        //}



        public List <ModelNotifiedForProducts> GetAllProducts(out string error)
        {
            error = null;
            try
            {
                ProductsBsn                     bsn           = new ProductsBsn(wpfConfig);
                List <ProductsInfo>             dbItems       = bsn.GetAll();
                List <ModelNotifiedForProducts> notifiedItems = new List <ModelNotifiedForProducts>();

                foreach (ProductsInfo dbItem in dbItems)
                {
                    ModelNotifiedForProducts itemToAdd = new ModelNotifiedForProducts();
                    Cloner.CopyAllTo(typeof(ProductsInfo), dbItem, typeof(ModelNotifiedForProducts), itemToAdd);
                    itemToAdd.ItemChanged = false;
                    itemToAdd.NewItem     = false;
                    notifiedItems.Add(itemToAdd);
                }

                return(notifiedItems);
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(null);
        }
Example #2
0
        /// <summary>
        /// Get all itens filtering direct in DB. Up: More optimized because filters DB. Down: less flexible, don't support dynamic filters.
        /// </summary>
        /// <param name="generalBodyGet"></param>
        /// <param name="error"></param>
        /// <returns></returns>
        public List <GetProductsView> GetAllWithDBFilter(GeneralBodyGet generalBodyGet, out RestExceptionError error)
        {
            try
            {
                if ((generalBodyGet == null) || (generalBodyGet.Filters == null) || (generalBodyGet.Filters.Count == 0))
                {
                    error = new RestExceptionError();
                    error.ExceptionMessage = "";
                    error.InternalMessage  = "Url does not contains filter section";
                }

                error = null;
                ProductsBsn bsn = new ProductsBsn(restConfig);
                List <DataFilterExpressionDB> dbFilter = HelperRESTFilterToDB.FilterRestFilterToDBExpression(generalBodyGet.Filters);
                List <ProductsInfo>           dbItems  = bsn.GetAll(dbFilter);
                List <GetProductsView>        result   = new List <GetProductsView>();
                foreach (ProductsInfo item in dbItems)
                {
                    GetProductsView view = new GetProductsView();
                    Cloner.CopyAllTo(typeof(ProductsInfo), item, typeof(GetProductsView), view);
                    result.Add(view);
                }

                return(result);
            }
            catch (Exception ex)
            {
                error = new RestExceptionError();
                error.ExceptionMessage = ex.Message;
            }
            return(null);
        }
Example #3
0
        /// <summary>
        /// Retrieve all data from Products table. Used to fill combo box.
        /// </summary>
        /// <returns>List of Products</returns>
        public List <ModelNotifiedForProducts> GetAll_Products(out string error)
        {
            error = null;
            ProductsBsn                     bsn           = new ProductsBsn(wpfConfig);
            List <ProductsInfo>             dbItems       = bsn.GetAll();
            List <ModelNotifiedForProducts> notifiedItems = new List <ModelNotifiedForProducts>();

            foreach (ProductsInfo dbItem in dbItems)
            {
                ModelNotifiedForProducts itemToAdd = new ModelNotifiedForProducts();
                Cloner.CopyAllTo(typeof(ProductsInfo), dbItem, typeof(ModelNotifiedForProducts), itemToAdd);
                notifiedItems.Add(itemToAdd);
            }
            return(notifiedItems);
        }
Example #4
0
        public List <GetProductsView> GetAll(out RestExceptionError error)
        {
            try
            {
                error = null;
                ProductsBsn            bsn     = new ProductsBsn(restConfig);
                List <ProductsInfo>    dbItems = bsn.GetAll();
                List <GetProductsView> result  = new List <GetProductsView>();
                foreach (ProductsInfo item in dbItems)
                {
                    GetProductsView view = new GetProductsView();
                    Cloner.CopyAllTo(typeof(ProductsInfo), item, typeof(GetProductsView), view);
                    result.Add(view);
                }

                return(result);
            }
            catch (Exception ex)
            {
                error = new RestExceptionError();
                error.ExceptionMessage = ex.Message;
            }
            return(null);
        }