//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); }
/// <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); }
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); }
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); }
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); }
/// <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); }
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; } }
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); }