OrderCartWindowPresenter.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using OOO_WriteAndClear.DBModels;
  2. using OOO_WriteAndClear.MVP.Models;
  3. using OOO_WriteAndClear.MVP.Models.OrderFormerer;
  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 OrderCartWindowPresenter : IOrderCartWindowContract.IPresenter
  13. {
  14. public OrderCartWindowPresenter(IOrderCartWindowContract.IView view)
  15. {
  16. _view = view;
  17. _model = new OrderCartWindowModel();
  18. }
  19. #region Реализация IOrderCartWindowContract.IPresenter
  20. public Order CurrentOrder => _model.OrderFormerer.Order;
  21. public void SetCurrentOrderFormerer(OrderFormerer orderFormerer)
  22. {
  23. _model.OrderFormerer = orderFormerer;
  24. UpdateOrderData(orderFormerer.Order);
  25. }
  26. public void AddProductUnitIntoOrder(string productArticle)
  27. {
  28. _model.AddProductUnitIntoOrder(productArticle);
  29. UpdateOrderData(_model.OrderFormerer.Order);
  30. }
  31. public void RemoveProductUnitFromOrder(string productArticle)
  32. {
  33. _model.RemoveProductUnitFromOrder(productArticle);
  34. UpdateOrderData(_model.OrderFormerer.Order);
  35. }
  36. public void RemoveProductFromOrder(string productArticle)
  37. {
  38. _model.RemoveProductFromOrder(productArticle);
  39. UpdateOrderData(_model.OrderFormerer.Order);
  40. }
  41. public void AddOrderInSystem(PickupPoint selectedPickupPoint)
  42. {
  43. _model.AddOrderInSystem(selectedPickupPoint);
  44. }
  45. public ICollection<PickupPoint> GetAllPickupPoints() =>
  46. _model.GetAllPickupPoints();
  47. #endregion
  48. private IOrderCartWindowContract.IView _view;
  49. private IOrderCartWindowContract.IModel _model;
  50. private void UpdateOrderData(Order order)
  51. {
  52. _view.OrderCostWithoutDiscount =
  53. string.Format("{0:f2} руб.", order.OrderCostWithoutDiscount);
  54. _view.OrderCostWithDiscount =
  55. string.Format("{0:f2} руб.", order.OrderCost);
  56. _view.OrderDiscount =
  57. string.Format("{0:f2} руб.", order.OrderDiscount);
  58. _view.OrderList = order.OrderProducts;
  59. }
  60. }
  61. }