/// <summary> /// Method fetches the Food Store corresponding to the passed foodStoreName /// </summary> /// <param name="foodStoreName"></param> /// <returns>returns List of Food_Store </returns> public List <Food_Store> GetFoodStoreByStoreName(string foodStoreName) { //check the validity of the input if (ModelState.IsValid) { try { //instantiate FoodStoreService class FoodStoreService fs = new FoodStoreService(); //Call GetFoodStoreByFoodName method to fetch all Food Stores corresponding to foodStoreName List <Food_Store> foodStores = fs.GetFoodStoreByStoreName(foodStoreName); //return the response return(foodStores); } catch (FoodOrderException) { //rethrow throw; } } else { //throw user defined exception object throw new FoodOrderException("The entered details to fetch the Food Stores are not valid"); } }
/// <summary> /// Method updates or edits the changes of the passed foodStore in the Food_Stores table /// </summary> /// <param name="foodStore"></param> /// <returns>boolean value</returns> public bool UpdateFoodStore(Food_Store foodStore) { //check the validity of the input if (ModelState.IsValid) { try { //instantiate FoodStoreService class FoodStoreService fs = new FoodStoreService(); //Call AddFoodStore method to fetch all Food Stores bool isUpdated = fs.UpdateFoodStore(foodStore); //return the response return(isUpdated); } catch (FoodOrderException) { //rethrow throw; } } else { //throw user defined exception object throw new FoodOrderException("The entered details to fetch the Food Stores are not valid"); } }
/// <summary> /// Method fetches the Food Store corresponding to the passed foodStoreId /// </summary> /// <param name="foodStoreId"></param> /// <returns>returns Food_Store type value</returns> public Food_Store GetFoodStoreById(int foodStoreId) { //check the validity of the input if (ModelState.IsValid) { try { //instantiate FoodService class FoodStoreService fs = new FoodStoreService(); //Call GetAllFoodStores() to fetch all Food Stores Food_Store foodStore = fs.GetFoodStoreById(foodStoreId); //return the response return(foodStore); } catch (FoodOrderException) { //rethrow throw; } } else { //throw user defined exception object throw new FoodOrderException("The entered details to fetch the Food Stores are not valid"); } }
/// <summary> /// Method Deletes the Food store with foodStoreId from table Food_Stores /// </summary> /// <param name="foodStoreId"></param> /// <returns>boolean value</returns> public bool DeleteFoodStoreById(int foodStoreId) { //check the validity of the input if (ModelState.IsValid) { try { //instantiate FoodStoreService class FoodStoreService fs = new FoodStoreService(); //Call GetAllFoodStores() to fetch all Food Stores bool isDeleted = fs.DeleteFoodStoreById(foodStoreId); //return the response return(isDeleted); } catch (FoodOrderException) { //rethrow throw; } } else { //throw user defined exception object throw new FoodOrderException("The foodStoreId is required "); } }