Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #3
0
        public void DeleteData(ModelNotifiedForProducts modelNotifiedForProducts, out string error)
        {
            ProductsBsn  bsn    = new ProductsBsn(wpfConfig);
            ProductsInfo dbItem = new ProductsInfo();

            Cloner.CopyAllTo(typeof(ModelNotifiedForProducts), modelNotifiedForProducts, typeof(ProductsInfo), dbItem);
            bsn.DeleteByID(dbItem, out error);
        }
Beispiel #4
0
        public void AddData(ModelNotifiedForProducts modelNotifiedForProducts, out string error)
        {
            ProductsBsn  bsn    = new ProductsBsn(wpfConfig);
            ProductsInfo dbItem = new ProductsInfo();

            Cloner.CopyAllTo(typeof(ModelNotifiedForProducts), modelNotifiedForProducts, typeof(ProductsInfo), dbItem);
            bsn.InsertOne(dbItem, out error);
            modelNotifiedForProducts.NewItem = false;
            Cloner.CopyAllTo(typeof(ProductsInfo), dbItem, typeof(ModelNotifiedForProducts), modelNotifiedForProducts);
        }
Beispiel #5
0
        public ModelNotifiedForProducts GetProductsByID(int ProductID, out string error)
        {
            error = null;
            ProductsBsn              bsn    = new ProductsBsn(wpfConfig);
            ProductsInfo             dbItem = bsn.GetValueByID(ProductID);
            ModelNotifiedForProducts item   = new ModelNotifiedForProducts();

            Cloner.CopyAllTo(typeof(ProductsInfo), dbItem, typeof(ModelNotifiedForProducts), item);
            return(item);
        }
Beispiel #6
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);
        }
Beispiel #7
0
        public void TryUpdate(UpdateProductsView viewToUpdate, out RestExceptionError error)
        {
            error = null;
            ProductsInfo dbViewToInclude = new ProductsInfo();

            try
            {
                Cloner.CopyAllTo(typeof(UpdateProductsView), viewToUpdate, typeof(ProductsInfo), dbViewToInclude);
            }
            catch (Exception ex)
            {
                error = new RestExceptionError();
                error.InternalMessage  = "Internal Error parsing data for (Products.TryUpdate/Parsing)";
                error.ExceptionMessage = ex.Message;
                error.SourceError      = RestExceptionError._SourceError.ServerSide;
                error.StackTrace       = ex.StackTrace;
            }

            try
            {
                ProductsBsn bsn     = new ProductsBsn(restConfig);
                string      dbError = null;
                bsn.UpdateOne(dbViewToInclude, out dbError);
                if (dbError != null)
                {
                    error = new RestExceptionError();
                    error.InternalMessage  = "Internal Error Save data for [Products.TryUpdate]";
                    error.ExceptionMessage = dbError;
                    error.SourceError      = RestExceptionError._SourceError.ServerSide;
                    error.StackTrace       = "";
                }
            }
            catch (Exception ex)
            {
                error = new RestExceptionError();
                error.InternalMessage  = "Internal Error Update data for [Products.TryUpdate]";
                error.ExceptionMessage = ex.Message;
                error.SourceError      = RestExceptionError._SourceError.ServerSide;
                error.StackTrace       = ex.StackTrace;
            }
        }
Beispiel #8
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);
        }