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



        public List <ModelNotifiedForSuppliers> GetAllSuppliers(out string error)
        {
            error = null;
            try
            {
                SuppliersBsn                     bsn           = new SuppliersBsn(wpfConfig);
                List <SuppliersInfo>             dbItems       = bsn.GetAll();
                List <ModelNotifiedForSuppliers> notifiedItems = new List <ModelNotifiedForSuppliers>();

                foreach (SuppliersInfo dbItem in dbItems)
                {
                    ModelNotifiedForSuppliers itemToAdd = new ModelNotifiedForSuppliers();
                    Cloner.CopyAllTo(typeof(SuppliersInfo), dbItem, typeof(ModelNotifiedForSuppliers), 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 <GetSuppliersView> 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;
                SuppliersBsn bsn = new SuppliersBsn(restConfig);
                List <DataFilterExpressionDB> dbFilter = HelperRESTFilterToDB.FilterRestFilterToDBExpression(generalBodyGet.Filters);
                List <SuppliersInfo>          dbItems  = bsn.GetAll(dbFilter);
                List <GetSuppliersView>       result   = new List <GetSuppliersView>();
                foreach (SuppliersInfo item in dbItems)
                {
                    GetSuppliersView view = new GetSuppliersView();
                    Cloner.CopyAllTo(typeof(SuppliersInfo), item, typeof(GetSuppliersView), view);
                    result.Add(view);
                }

                return(result);
            }
            catch (Exception ex)
            {
                error = new RestExceptionError();
                error.ExceptionMessage = ex.Message;
            }
            return(null);
        }
Beispiel #3
0
        public void DeleteData(ModelNotifiedForSuppliers modelNotifiedForSuppliers, out string error)
        {
            SuppliersBsn  bsn    = new SuppliersBsn(wpfConfig);
            SuppliersInfo dbItem = new SuppliersInfo();

            Cloner.CopyAllTo(typeof(ModelNotifiedForSuppliers), modelNotifiedForSuppliers, typeof(SuppliersInfo), dbItem);
            bsn.DeleteByID(dbItem, out error);
        }
Beispiel #4
0
        public void AddData(ModelNotifiedForSuppliers modelNotifiedForSuppliers, out string error)
        {
            SuppliersBsn  bsn    = new SuppliersBsn(wpfConfig);
            SuppliersInfo dbItem = new SuppliersInfo();

            Cloner.CopyAllTo(typeof(ModelNotifiedForSuppliers), modelNotifiedForSuppliers, typeof(SuppliersInfo), dbItem);
            bsn.InsertOne(dbItem, out error);
            modelNotifiedForSuppliers.NewItem = false;
            Cloner.CopyAllTo(typeof(SuppliersInfo), dbItem, typeof(ModelNotifiedForSuppliers), modelNotifiedForSuppliers);
        }
Beispiel #5
0
        public ModelNotifiedForSuppliers GetSuppliersByID(int SupplierID, out string error)
        {
            error = null;
            SuppliersBsn              bsn    = new SuppliersBsn(wpfConfig);
            SuppliersInfo             dbItem = bsn.GetValueByID(SupplierID);
            ModelNotifiedForSuppliers item   = new ModelNotifiedForSuppliers();

            Cloner.CopyAllTo(typeof(SuppliersInfo), dbItem, typeof(ModelNotifiedForSuppliers), item);
            return(item);
        }
Beispiel #6
0
        /// <summary>
        /// Retrieve all data from Suppliers table. Used to fill combo box.
        /// </summary>
        /// <returns>List of Suppliers</returns>
        public List <ModelNotifiedForSuppliers> GetAll_Suppliers(out string error)
        {
            error = null;
            SuppliersBsn                     bsn           = new SuppliersBsn(wpfConfig);
            List <SuppliersInfo>             dbItems       = bsn.GetAll();
            List <ModelNotifiedForSuppliers> notifiedItems = new List <ModelNotifiedForSuppliers>();

            foreach (SuppliersInfo dbItem in dbItems)
            {
                ModelNotifiedForSuppliers itemToAdd = new ModelNotifiedForSuppliers();
                Cloner.CopyAllTo(typeof(SuppliersInfo), dbItem, typeof(ModelNotifiedForSuppliers), itemToAdd);
                notifiedItems.Add(itemToAdd);
            }
            return(notifiedItems);
        }
Beispiel #7
0
        public void TryUpdate(UpdateSuppliersView viewToUpdate, out RestExceptionError error)
        {
            error = null;
            SuppliersInfo dbViewToInclude = new SuppliersInfo();

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

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

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