예제 #1
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);
        }
예제 #2
0
        public ModelNotifiedForProducts GetProductsByID(int ProductID, out string error)
        {
            error = null;
            ProductsGenericREST      ProductsGenericREST      = new ProductsGenericREST(wpfConfig);
            GetProductsView          getProductsView          = ProductsGenericREST.GetByPK <GetProductsView>(ProductID, out error)[0];
            ModelNotifiedForProducts modelNotifiedForProducts = new ModelNotifiedForProducts();

            Cloner.CopyAllTo(typeof(GetProductsView), getProductsView, typeof(ModelNotifiedForProducts), modelNotifiedForProducts);
            return(modelNotifiedForProducts);
        }
예제 #3
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);
        }