/// <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); }
//private void CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) //{ //Notify("IncludeFolders"); //} public List <ModelNotifiedForCategories> GetAllCategories(out string error) { error = null; try { CategoriesBsn bsn = new CategoriesBsn(wpfConfig); List <CategoriesInfo> dbItems = bsn.GetAll(); List <ModelNotifiedForCategories> notifiedItems = new List <ModelNotifiedForCategories>(); foreach (CategoriesInfo dbItem in dbItems) { ModelNotifiedForCategories itemToAdd = new ModelNotifiedForCategories(); Cloner.CopyAllTo(typeof(CategoriesInfo), dbItem, typeof(ModelNotifiedForCategories), itemToAdd); itemToAdd.ItemChanged = false; itemToAdd.NewItem = false; notifiedItems.Add(itemToAdd); } return(notifiedItems); } catch (Exception ex) { error = ex.Message; } return(null); }
public void DeleteData(ModelNotifiedForCategories modelNotifiedForCategories, out string error) { CategoriesBsn bsn = new CategoriesBsn(wpfConfig); CategoriesInfo dbItem = new CategoriesInfo(); Cloner.CopyAllTo(typeof(ModelNotifiedForCategories), modelNotifiedForCategories, typeof(CategoriesInfo), dbItem); bsn.DeleteByID(dbItem, out error); }
public void AddData(ModelNotifiedForCategories modelNotifiedForCategories, out string error) { CategoriesBsn bsn = new CategoriesBsn(wpfConfig); CategoriesInfo dbItem = new CategoriesInfo(); Cloner.CopyAllTo(typeof(ModelNotifiedForCategories), modelNotifiedForCategories, typeof(CategoriesInfo), dbItem); bsn.InsertOne(dbItem, out error); modelNotifiedForCategories.NewItem = false; Cloner.CopyAllTo(typeof(CategoriesInfo), dbItem, typeof(ModelNotifiedForCategories), modelNotifiedForCategories); }
public ModelNotifiedForCategories GetCategoriesByID(int CategoryID, out string error) { error = null; CategoriesBsn bsn = new CategoriesBsn(wpfConfig); CategoriesInfo dbItem = bsn.GetValueByID(CategoryID); ModelNotifiedForCategories item = new ModelNotifiedForCategories(); Cloner.CopyAllTo(typeof(CategoriesInfo), dbItem, typeof(ModelNotifiedForCategories), item); return(item); }
/// <summary> /// Retrieve all data from Categories table. Used to fill combo box. /// </summary> /// <returns>List of Categories</returns> public List <ModelNotifiedForCategories> GetAll_Categories(out string error) { error = null; CategoriesBsn bsn = new CategoriesBsn(wpfConfig); List <CategoriesInfo> dbItems = bsn.GetAll(); List <ModelNotifiedForCategories> notifiedItems = new List <ModelNotifiedForCategories>(); foreach (CategoriesInfo dbItem in dbItems) { ModelNotifiedForCategories itemToAdd = new ModelNotifiedForCategories(); Cloner.CopyAllTo(typeof(CategoriesInfo), dbItem, typeof(ModelNotifiedForCategories), itemToAdd); notifiedItems.Add(itemToAdd); } return(notifiedItems); }
public void TryUpdate(UpdateCategoriesView viewToUpdate, out RestExceptionError error) { error = null; CategoriesInfo dbViewToInclude = new CategoriesInfo(); try { Cloner.CopyAllTo(typeof(UpdateCategoriesView), viewToUpdate, typeof(CategoriesInfo), dbViewToInclude); } catch (Exception ex) { error = new RestExceptionError(); error.InternalMessage = "Internal Error parsing data for (Categories.TryUpdate/Parsing)"; error.ExceptionMessage = ex.Message; error.SourceError = RestExceptionError._SourceError.ServerSide; error.StackTrace = ex.StackTrace; } try { CategoriesBsn bsn = new CategoriesBsn(restConfig); string dbError = null; bsn.UpdateOne(dbViewToInclude, out dbError); if (dbError != null) { error = new RestExceptionError(); error.InternalMessage = "Internal Error Save data for [Categories.TryUpdate]"; error.ExceptionMessage = dbError; error.SourceError = RestExceptionError._SourceError.ServerSide; error.StackTrace = ""; } } catch (Exception ex) { error = new RestExceptionError(); error.InternalMessage = "Internal Error Update data for [Categories.TryUpdate]"; error.ExceptionMessage = ex.Message; error.SourceError = RestExceptionError._SourceError.ServerSide; error.StackTrace = ex.StackTrace; } }
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); }
static void Main(string[] args) { //BrandsBsn brandsBsn = new BrandsBsn(); //BrandsModel brandsModel = new BrandsModel("Shar", "Nemacka"); //brandsBsn.Insert(brandsModel); //List<BrandsModel> list = brandsBsn.Read(); //foreach (var x in list) //{ // Console.WriteLine(x.Name + ' ' + x.Country); //} //CategoriesBsn categoriesBsn = new CategoriesBsn(); //CategoriesModel categoriesModel = new CategoriesModel("Brasno", "Proso i Heljda"); //categoriesBsn.Insert(categoriesModel); //List<CategoriesModel> list1 = categoriesBsn.Read(); //foreach (var x in list1) //{ // Console.WriteLine(x.Name + ' ' + x.Description); //} CategoriesBsn categoriesBsn = new CategoriesBsn(); CategoriesModel categoriesModel = categoriesBsn.getCategoryByNameBsn("Brasno"); Console.WriteLine(categoriesModel.ToString()); //List<ProductModel> productModels = new List<ProductModel>(); //ProductBsn productBsn = new ProductBsn(); //productModels = productBsn.Read(); //foreach (var l in productModels) //{ // Console.WriteLine(l.ToString()); //} //ProductModel productModel = new ProductModel("papaja", 2, 3, 400, 400); //productBsn.Insert(productModel); //ProductBsn productBsn = new ProductBsn(); //List<ProductModel> productModels = productBsn.Read(); //ProductModel productModelU = new ProductModel("smoki", 2, 3, 400, 300); //int idU = 6; //productBsn.Update(idU, productModelU); //int idD = 7; //productBsn.Delete(idD); //RestaurantsBsn restaurantsBsn = new RestaurantsBsn(); //RestaurantsModel restaurantsModel = new RestaurantsModel("Aleksandar", "Vidikovac", "www.aleksandar.com", "Restoran sa pogledom"); //restaurantsBsn.Insert(restaurantsModel); //List<RestaurantsModel> restaurantsModels = restaurantsBsn.Read(); //foreach (var l in restaurantsModels) //{ // Console.WriteLine(l.ToString()); //} //RecipesBsn recipesBsn = new RecipesBsn(); //RecipesModel recipesModel = new RecipesModel("Kolac sa bananama", "solja brasna ,solja pavlake"); //recipesBsn.Insert(recipesModel); //List<RecipesModel> recipesModels = recipesBsn.Read(); //foreach (var x in recipesModels) //{ // Console.WriteLine(x.Name + ' ' + x.Description); //} //UserBsn userBsn = new UserBsn(); //List<UserModel> listUsers = userBsn.Read(); //foreach (var l in listUsers) //{ // Console.WriteLine(l.ToString()); //} //UserModel userModel = new UserModel("Pera", "Peric", "Petrovac", "0631234567", "*****@*****.**"); //userBsn.Insert(userModel); //userBsn.Read(); //OrdersBsn ordersBsn = new OrdersBsn(); //OrdersModel ordersModel = new OrdersModel(1, DateTime.Now, 50.3); //ordersBsn.Insert(ordersModel); //UserBsn userBsn = new UserBsn(); //string name = "Radovan"; //UserModel userModel = userBsn.GetUserByNameBsn(name); //Console.WriteLine(userModel.ToString()); //UserBsn userBsn = new UserBsn(); //List<UserModel> list = userBsn.Read(); //UserModel deletedUser = userBsn.DeleteMaxIdBSN(); //Console.WriteLine("User" + ' ' + deletedUser.ToString() + ' ' + "is deleted"); Console.ReadLine(); }