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



        public List <ModelNotifiedForShippers> GetAllShippers(out string error)
        {
            error = null;
            try
            {
                ShippersBsn                     bsn           = new ShippersBsn(wpfConfig);
                List <ShippersInfo>             dbItems       = bsn.GetAll();
                List <ModelNotifiedForShippers> notifiedItems = new List <ModelNotifiedForShippers>();

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

                return(notifiedItems);
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(null);
        }
예제 #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 <GetShippersView> 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;
                ShippersBsn bsn = new ShippersBsn(restConfig);
                List <DataFilterExpressionDB> dbFilter = HelperRESTFilterToDB.FilterRestFilterToDBExpression(generalBodyGet.Filters);
                List <ShippersInfo>           dbItems  = bsn.GetAll(dbFilter);
                List <GetShippersView>        result   = new List <GetShippersView>();
                foreach (ShippersInfo item in dbItems)
                {
                    GetShippersView view = new GetShippersView();
                    Cloner.CopyAllTo(typeof(ShippersInfo), item, typeof(GetShippersView), view);
                    result.Add(view);
                }

                return(result);
            }
            catch (Exception ex)
            {
                error = new RestExceptionError();
                error.ExceptionMessage = ex.Message;
            }
            return(null);
        }
예제 #3
0
        public void DeleteData(ModelNotifiedForShippers modelNotifiedForShippers, out string error)
        {
            ShippersBsn  bsn    = new ShippersBsn(wpfConfig);
            ShippersInfo dbItem = new ShippersInfo();

            Cloner.CopyAllTo(typeof(ModelNotifiedForShippers), modelNotifiedForShippers, typeof(ShippersInfo), dbItem);
            bsn.DeleteByID(dbItem, out error);
        }
예제 #4
0
        public void AddData(ModelNotifiedForShippers modelNotifiedForShippers, out string error)
        {
            ShippersBsn  bsn    = new ShippersBsn(wpfConfig);
            ShippersInfo dbItem = new ShippersInfo();

            Cloner.CopyAllTo(typeof(ModelNotifiedForShippers), modelNotifiedForShippers, typeof(ShippersInfo), dbItem);
            bsn.InsertOne(dbItem, out error);
            modelNotifiedForShippers.NewItem = false;
            Cloner.CopyAllTo(typeof(ShippersInfo), dbItem, typeof(ModelNotifiedForShippers), modelNotifiedForShippers);
        }
예제 #5
0
        public ModelNotifiedForShippers GetShippersByID(int ShipperID, out string error)
        {
            error = null;
            ShippersBsn              bsn    = new ShippersBsn(wpfConfig);
            ShippersInfo             dbItem = bsn.GetValueByID(ShipperID);
            ModelNotifiedForShippers item   = new ModelNotifiedForShippers();

            Cloner.CopyAllTo(typeof(ShippersInfo), dbItem, typeof(ModelNotifiedForShippers), item);
            return(item);
        }
예제 #6
0
        /// <summary>
        /// Retrieve all data from Shippers table. Used to fill combo box.
        /// </summary>
        /// <returns>List of Shippers</returns>
        public List <ModelNotifiedForShippers> GetAll_Shippers(out string error)
        {
            error = null;
            ShippersBsn                     bsn           = new ShippersBsn(wpfConfig);
            List <ShippersInfo>             dbItems       = bsn.GetAll();
            List <ModelNotifiedForShippers> notifiedItems = new List <ModelNotifiedForShippers>();

            foreach (ShippersInfo dbItem in dbItems)
            {
                ModelNotifiedForShippers itemToAdd = new ModelNotifiedForShippers();
                Cloner.CopyAllTo(typeof(ShippersInfo), dbItem, typeof(ModelNotifiedForShippers), itemToAdd);
                notifiedItems.Add(itemToAdd);
            }
            return(notifiedItems);
        }
예제 #7
0
        public void TryUpdate(UpdateShippersView viewToUpdate, out RestExceptionError error)
        {
            error = null;
            ShippersInfo dbViewToInclude = new ShippersInfo();

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

            try
            {
                ShippersBsn bsn     = new ShippersBsn(restConfig);
                string      dbError = null;
                bsn.UpdateOne(dbViewToInclude, out dbError);
                if (dbError != null)
                {
                    error = new RestExceptionError();
                    error.InternalMessage  = "Internal Error Save data for [Shippers.TryUpdate]";
                    error.ExceptionMessage = dbError;
                    error.SourceError      = RestExceptionError._SourceError.ServerSide;
                    error.StackTrace       = "";
                }
            }
            catch (Exception ex)
            {
                error = new RestExceptionError();
                error.InternalMessage  = "Internal Error Update data for [Shippers.TryUpdate]";
                error.ExceptionMessage = ex.Message;
                error.SourceError      = RestExceptionError._SourceError.ServerSide;
                error.StackTrace       = ex.StackTrace;
            }
        }
예제 #8
0
        public List <GetShippersView> GetAll(out RestExceptionError error)
        {
            try
            {
                error = null;
                ShippersBsn            bsn     = new ShippersBsn(restConfig);
                List <ShippersInfo>    dbItems = bsn.GetAll();
                List <GetShippersView> result  = new List <GetShippersView>();
                foreach (ShippersInfo item in dbItems)
                {
                    GetShippersView view = new GetShippersView();
                    Cloner.CopyAllTo(typeof(ShippersInfo), item, typeof(GetShippersView), view);
                    result.Add(view);
                }

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