123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- using OOO_WriteAndClear.DBModels;
- using OOO_WriteAndClear.MVP.Models;
- using OOO_WriteAndClear.MVP.Models.OrderFormerer;
- using OOO_WriteAndClear.MVP.MVPInterfaces;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace OOO_WriteAndClear.MVP.Presenters
- {
- public class OrderCartWindowPresenter : IOrderCartWindowContract.IPresenter
- {
- public OrderCartWindowPresenter(IOrderCartWindowContract.IView view)
- {
- _view = view;
- _model = new OrderCartWindowModel();
- }
- #region Реализация IOrderCartWindowContract.IPresenter
- public Order CurrentOrder => _model.OrderFormerer.Order;
- public void SetCurrentOrderFormerer(OrderFormerer orderFormerer)
- {
- _model.OrderFormerer = orderFormerer;
- UpdateOrderData(orderFormerer.Order);
- }
- public void AddProductUnitIntoOrder(string productArticle)
- {
- _model.AddProductUnitIntoOrder(productArticle);
- UpdateOrderData(_model.OrderFormerer.Order);
- }
- public void RemoveProductUnitFromOrder(string productArticle)
- {
- _model.RemoveProductUnitFromOrder(productArticle);
- UpdateOrderData(_model.OrderFormerer.Order);
- }
- public void RemoveProductFromOrder(string productArticle)
- {
- _model.RemoveProductFromOrder(productArticle);
- UpdateOrderData(_model.OrderFormerer.Order);
- }
- public void AddOrderInSystem(PickupPoint selectedPickupPoint)
- {
- _model.AddOrderInSystem(selectedPickupPoint);
- }
- public ICollection<PickupPoint> GetAllPickupPoints() =>
- _model.GetAllPickupPoints();
- #endregion
- private IOrderCartWindowContract.IView _view;
- private IOrderCartWindowContract.IModel _model;
- private void UpdateOrderData(Order order)
- {
- _view.OrderCostWithoutDiscount =
- string.Format("{0:f2} руб.", order.OrderCostWithoutDiscount);
- _view.OrderCostWithDiscount =
- string.Format("{0:f2} руб.", order.OrderCost);
- _view.OrderDiscount =
- string.Format("{0:f2} руб.", order.OrderDiscount);
- _view.OrderList = order.OrderProducts;
- }
- }
- }
|