public void UpdateOrder(BO.Order order) { DO.Order dalOrder = new DO.Order(); try { dalOrder = dal.RecieveOrder(order.Key); } catch (MissingMemberException e) { throw e; } if (!AbleToChangeOrderStatus(order)) { throw new InvalidOperationException("You can't change a order status after other placed/ alradey irrelevant"); } else { //check if order placed now if (IsOpenOrder(Conversions.CastingToBO_Order(dalOrder))) { if (order.Status == BO.Order_Status.EMAIL_SENT && dalOrder.Status != DO.Order_Status.EMAIL_SENT) { SendEmail(order); } if (order.Status == BO.Order_Status.APPROVED) { PlaceOrder(order); order.CloseDate = DateTime.Now; } } } dal.UpdateOrder(Conversions.CastingToDO_Order(order)); }
public bool AbleToChangeOrderStatus(BO.Order order)// { DO.Order dOrder = dal.RecieveOrder(order.Key); return(dOrder.Status != DO.Order_Status.APPROVED && dOrder.Status != DO.Order_Status.IRRELEVANT); }
public bool IsOpenOrder(BO.Order bOrder) { DO.Order order = dal.RecieveOrder(bOrder.Key); return(order.Status != DO.Order_Status.CLIENT_CLOSED && order.Status != DO.Order_Status.IGNORED_CLOSED && order.Status != DO.Order_Status.IRRELEVANT); }
public Order RecieveOrder(int key) { DO.Order order = XML.RecieveOrder(key); return(order == null ? throw new MissingMemberException($"Order {key} dosen't Exist") : order); }