/// <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 <GetCategoriesView> 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; CategoriesBsn bsn = new CategoriesBsn(restConfig); List <DataFilterExpressionDB> dbFilter = HelperRESTFilterToDB.FilterRestFilterToDBExpression(generalBodyGet.Filters); List <CategoriesInfo> dbItems = bsn.GetAll(dbFilter); List <GetCategoriesView> result = new List <GetCategoriesView>(); foreach (CategoriesInfo item in dbItems) { GetCategoriesView view = new GetCategoriesView(); Cloner.CopyAllTo(typeof(CategoriesInfo), item, typeof(GetCategoriesView), view); result.Add(view); } return(result); } catch (Exception ex) { error = new RestExceptionError(); error.ExceptionMessage = ex.Message; } return(null); }
public ModelNotifiedForCategories GetCategoriesByID(int CategoryID, out string error) { error = null; CategoriesGenericREST CategoriesGenericREST = new CategoriesGenericREST(wpfConfig); GetCategoriesView getCategoriesView = CategoriesGenericREST.GetByPK <GetCategoriesView>(CategoryID, out error)[0]; ModelNotifiedForCategories modelNotifiedForCategories = new ModelNotifiedForCategories(); Cloner.CopyAllTo(typeof(GetCategoriesView), getCategoriesView, typeof(ModelNotifiedForCategories), modelNotifiedForCategories); return(modelNotifiedForCategories); }
public List <GetCategoriesView> GetAll(out RestExceptionError error) { try { error = null; CategoriesBsn bsn = new CategoriesBsn(restConfig); List <CategoriesInfo> dbItems = bsn.GetAll(); List <GetCategoriesView> result = new List <GetCategoriesView>(); foreach (CategoriesInfo item in dbItems) { GetCategoriesView view = new GetCategoriesView(); Cloner.CopyAllTo(typeof(CategoriesInfo), item, typeof(GetCategoriesView), view); result.Add(view); } return(result); } catch (Exception ex) { error = new RestExceptionError(); error.ExceptionMessage = ex.Message; } return(null); }