Example #1
0
 public RecipeEntity MapRecipeListModelToEntity(RecipeListModel recipeListModel)
 {
     return(new RecipeEntity
     {
         Name = recipeListModel.Name,
         FoodCategory = recipeListModel.FoodCategory,
         FoodSpecialDiet = recipeListModel.FoodSpecialDiet,
         DegreeOfDifficulty = recipeListModel.DegreeOfDifficulty
     });
 }
        /// <summary>
        /// This method brings all the recipes from an especific company sorted by rating
        /// @author Jose A.
        /// </summary>
        private async void Sort_Rating(object sender, EventArgs e)
        {
            HttpClient client = new HttpClient();
            string     url    = "http://" + LoginPage.ip + ":6969/sorting/getRatingsCompany/" + company1.Email;
            var        result = await client.GetAsync(url);

            var             json       = result.Content.ReadAsStringAsync().Result;
            RecipeListModel recipeList = RecipeListModel.FromJson(json);

            StartList(recipeList);
        }
        public void GetAll_FromSeeded_DoesNotThrowAndEqualsSeeded()
        {
            //Arrange
            RecipeListModel listModel = RecipeMapper.MapEntityToListModel(RecipeSeeds.RecipeEntity);

            //Act
            IEnumerable <RecipeListModel> returnedModel = _repositorySUT.GetAll();

            //Assert
            Assert.Equal(new [] { listModel }, returnedModel);
        }
Example #4
0
        /// <summary>
        /// This method pulls the search in case it was a recipe search just by name
        /// @author Jose A.
        /// </summary>
        private async void Search_Name_R()
        {
            HttpClient client = new HttpClient();
            string     url    = "http://" + LoginPage.ip + ":6969/searchRecipe/" + searchKey + "/";
            var        result = await client.GetAsync(url);

            var             json     = result.Content.ReadAsStringAsync().Result;
            RecipeListModel newmodel = RecipeListModel.FromJson(json);

            StartList_R(newmodel);
        }
Example #5
0
 /// <summary>
 /// This method starts the list travel by adding the head data for recipe lists
 /// @author Jose A.
 /// </summary>
 public void StartRecipeList(RecipeListModel model)
 {
     InitRecipeList();
     if (model.Head.Next != null)
     {
         RecipeList.Add(model.Head.Data);
         RecipeListAdd(model.Head.Next);
     }
     else
     {
         RecipeList.Add(model.Head.Data);
         RecipeListReturn();
     }
 }
 /// <summary>
 /// This method take the first element and add it
 /// @author Jose A.
 /// </summary>
 public void StartList(RecipeListModel model)
 {
     InitList();
     if (model.Head.Next != null)
     {
         CompanyListView.Add(model.Head.Data);
         ListAdd(model.Head.Next);
     }
     else
     {
         CompanyListView.Add(model.Head.Data);
         ListReturn();
     }
 }
Example #7
0
 /// <summary>
 /// This method starts the list traverse by first adding the data from the head for recipe lists.
 /// @author Jose A.
 /// </summary>
 public void StartList_R(RecipeListModel model)
 {
     InitList();
     if (model.Head.Next != null)
     {
         ObjectList.Add(model.Head.Data);
         ListAdd_R(model.Head.Next);
     }
     else
     {
         ObjectList.Add(model.Head.Data);
         ListReturn();
     }
 }
 /// <summary>
 /// Sets upp all the ViewModels and Models
 /// </summary>
 public ViewModelLocator()
 {
     _messageBoxService = new MessageBoxService();
     _loginModel        = new LoginModel(new UserHttpCollector(5));
     _foodplanCollector = new FoodplanHttpCollector();
     _loginViewModel    = new LoginViewModel(_loginModel, _messageBoxService, new WindowOpeningService());
     _recipeListModel   = new RecipeListModel(new RecipeHTTPCollector());
     _shoppingListModel = new ScheduledShoppingListModel
                              (new ItemHttpCollector(), new TimerScheduler(60), _loginModel);
     _shoppingListViewModel = new ShoppingListViewModel(_shoppingListModel);
     _foodplanModel         = new FoodplanModel
                                  (_foodplanCollector, _shoppingListModel, _recipeListModel, _loginModel, _messageBoxService);
     _recipeViewModel          = new RecipeListViewModel(_recipeListModel, 300, _foodplanModel, _messageBoxService);
     _addRecipeWindowViewModel = new AddRecipeWindowViewModel(_recipeListModel, new DialogImageChooser());
     _foodplanViewModel        = new FoodplanViewModel(_foodplanModel);
     _mwmvvm = new MainWindowViewModel();
 }
        /// <summary>
        /// This method create a new HTTP client and execute async method with the server to get the company data
        /// @author Jose A.
        /// </summary>
        private async void Pull_Search_Request()
        {
            HttpClient client = new HttpClient();
            string     url    = "http://" + LoginPage.ip + ":6969/company/getRecipe/" + company1.Email + "/";
            var        result = await client.GetAsync(url);

            var             json          = result.Content.ReadAsStringAsync().Result;
            RecipeListModel listofrecipes = RecipeListModel.FromJson(json);

            if (listofrecipes.Length == 0)
            {
                return;
            }
            else
            {
                StartList(listofrecipes);
            }
        }
Example #10
0
        /// <summary>
        /// This method brings all the user's recipes from the server and starts the list travel
        /// @author Jose A.
        /// </summary>
        private async void Pull_Search_Request()
        {
            HttpClient client = new HttpClient();
            string     url    = "http://" + LoginPage.ip + ":6969/getRecipe/" + LoginPage.CURRENTUSER.Email + "/user";
            var        result = await client.GetAsync(url);

            var             json          = result.Content.ReadAsStringAsync().Result;
            RecipeListModel listofrecipes = RecipeListModel.FromJson(json);

            Console.WriteLine("RESULT" + json);
            if (listofrecipes.Length == 0)
            {
                return;
            }
            else
            {
                StartList(listofrecipes);
            }
        }
Example #11
0
        /// <summary>
        /// This method pulls the search in case it was a recipe search using filters
        /// @author Jose A.
        /// </summary>
        private async void Pull_Search_Request_R()
        {
            HttpClient client = new HttpClient();
            string     url    = "http://" + LoginPage.ip + ":6969/searchRecipe";

            REST_API_RecipeSearchModel.RecipeS searchvalues = new REST_API_RecipeSearchModel.RecipeS();
            searchvalues.Search     = searchKey;
            searchvalues.TypeOfDish = Type_;
            searchvalues.Servings   = Servings;
            searchvalues.Duration   = Duration;
            String jsonSearch = JsonConvert.SerializeObject(searchvalues);
            var    datasent   = new StringContent(jsonSearch);

            datasent.Headers.ContentType.MediaType = "application/json";
            var result = await client.PostAsync(url, datasent);

            var             json     = result.Content.ReadAsStringAsync().Result;
            RecipeListModel newmodel = RecipeListModel.FromJson(json);

            StartList_R(newmodel);
        }
Example #12
0
 private void SelectRecipe(RecipeListModel recipeListModel)
 {
     this.MessengerInstance
     .Send <SelectedRecipeMessage>(
         new SelectedRecipeMessage(recipeListModel));
 }
Example #13
0
 private void RecipeSelected(RecipeListModel recipeListModel) => mediator.Send(new RecipeSelectedMessage {
     Id = recipeListModel.Id
 });
 public void SetUp()
 {
     _uut       = new RecipeListModel(_collector);
     _collector = Substitute.For <IRecipeCollector>();
     _uut.SetCollector(_collector);
 }
 public SelectedRecipeMessage(RecipeListModel recipeListModel)
 {
     RecipeListModel = recipeListModel;
 }
Example #16
0
 private void RecipeSelected(RecipeListModel recipeListModel) => _mediator.Send(new SelectedMessage <RecipeWrapper> {
     Id = recipeListModel.Id
 });