Пример #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 <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);
        }
Пример #2
0
        public ModelNotifiedForShippers GetShippersByID(int ShipperID, out string error)
        {
            error = null;
            ShippersGenericREST      ShippersGenericREST      = new ShippersGenericREST(wpfConfig);
            GetShippersView          getShippersView          = ShippersGenericREST.GetByPK <GetShippersView>(ShipperID, out error)[0];
            ModelNotifiedForShippers modelNotifiedForShippers = new ModelNotifiedForShippers();

            Cloner.CopyAllTo(typeof(GetShippersView), getShippersView, typeof(ModelNotifiedForShippers), modelNotifiedForShippers);
            return(modelNotifiedForShippers);
        }
Пример #3
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);
        }