ProductsUserControlPresenter.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using OOO_WriteAndClear.DBModels;
  2. using OOO_WriteAndClear.MVP.Models.OrderFormerer;
  3. using OOO_WriteAndClear.MVP.Models.ProductsUserControlModel;
  4. using OOO_WriteAndClear.MVP.MVPInterfaces;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. namespace OOO_WriteAndClear.MVP.Presenters
  11. {
  12. public class ProductsUserControlPresenter : IProductsUserControlContract.IPresenter
  13. {
  14. public ProductsUserControlPresenter(IProductsUserControlContract.IView view)
  15. {
  16. _view = view;
  17. _model = new ProductsUserControlModel();
  18. }
  19. #region Реализация IProductsUserControlContract.IPresenter
  20. public int GetAllProductsCount() => _model.GetAllProductsCount();
  21. public ICollection<Product> FilterSearchSortProducts(FilterSearchSortParameters parameters)
  22. {
  23. _model.FilterSearchSortProducts(parameters);
  24. return _model.Products;
  25. }
  26. public async Task<ICollection<Product>> UpdateProductsList(FilterSearchSortParameters parameters)
  27. {
  28. await _model.UpdateProductsList(parameters);
  29. return _model.Products;
  30. }
  31. public void AddProductIntoOrder(Product product)
  32. {
  33. _model.AddProductIntoOrder(product, (order) => _view.ChangeDisplayingBasketData(order));
  34. }
  35. public void RemoveProductFromOrder(Product product)
  36. {
  37. _model.RemoveProductFromOrder(product, (order) => _view.ChangeDisplayingBasketData(order));
  38. }
  39. public OrderFormerer GetCurrentOrderFormerer() => _model.GetCurrentOrderFormerer();
  40. #endregion
  41. private IProductsUserControlContract.IView _view;
  42. private IProductsUserControlContract.IModel _model;
  43. }
  44. }