コード例 #1
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);
        }
コード例 #2
0
        public void TryInclude(CreateProductsView viewToInclude, out RestExceptionError error)
        {
            error = null;
            ProductsInfo dbViewToInclude = new ProductsInfo();

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

            try
            {
                ProductsBsn bsn     = new ProductsBsn(restConfig);
                string      dbError = null;
                bsn.InsertOne(dbViewToInclude, out dbError);
                if (dbError != null)
                {
                    error = new RestExceptionError();
                    error.InternalMessage  = "Internal Error Save data for [Products.TryInclude/Save]";
                    error.ExceptionMessage = dbError;
                    error.SourceError      = RestExceptionError._SourceError.ServerSide;
                    error.StackTrace       = "";
                }
            }
            catch (Exception ex)
            {
                error = new RestExceptionError();
                error.InternalMessage  = "Internal Error Save data for [Products.TryInclude/Save]";
                error.ExceptionMessage = ex.Message;
                error.SourceError      = RestExceptionError._SourceError.ServerSide;
                error.StackTrace       = ex.StackTrace;
            }
        }