Exemplo n.º 1
0
 //public void AddPayer(Person newPayer, float share)
 //{
 //    if (share < 0 || share > 1)
 //        throw new ArgumentOutOfRangeException("Argument 'share' must be a number between 0 and 1");
 //    if (share > Payers[Owner])
 //        throw new ArgumentOutOfRangeException("Argument 'share' must be smaller than the share of the owner of this OrderLine");
 //    Payers[Owner] = Payers[Owner] - share;
 //    Payers[newPayer] = share;
 //}
 //public void RemovePayer(Person payer)
 //{
 //    if (Payers[payer].Equals(Owner))
 //        throw new ArgumentException("Cannot remove the owner of the order line from payers");
 //    if (Payers.ContainsKey(payer))
 //    {
 //        Payers[Owner] = Payers[Owner] + Payers[payer];
 //        Payers.Remove(payer);
 //    }
 //}
 //public void TransferOwnerShip(Person newOwner)
 //{
 //    TransferPayShare(Owner, newOwner);
 //}
 //public void TransferPayShare(Person oldPayer, Person newPayer)
 //{
 //    if (Payers.ContainsKey(oldPayer))
 //    {
 //        if (oldPayer.Equals(Owner))
 //        {
 //            this.Owner = newPayer;
 //        }
 //        if (Payers.ContainsKey(newPayer))
 //        {
 //            Payers[newPayer] = Payers[newPayer] + Payers[oldPayer];
 //        }
 //        else
 //        {
 //            Payers[newPayer] = Payers[oldPayer];
 //        }
 //        Payers.Remove(oldPayer);
 //    }
 //}
 public void PayForAll(Person payer)
 {
     //Payers.Clear();
     //Payers[payer] = 1f;
     //this.Owner = payer;
     this.Owner = payer;
 }
Exemplo n.º 2
0
 //public Dictionary<Person, float> Payers { get; set; }
 //public List<SharedItemPayer> Payers { get; private set; }
 public OrderLine(Person owner, OrderableItem item)
 {
     this.Owner = owner;
     this.Item = item;
     //Payers = new Dictionary<Person, float>();
     //Payers[Owner] = 1f;
 }
Exemplo n.º 3
0
 public Person GetPerson(ClientIdentity clientId)
 {
     Person p = Persons.FirstOrDefault(x => x.ClientId.Equals(clientId));
     if (p == null)
     {
         p = new Person(clientId);
         Persons.Add(p);
     }
     return p;
 }
 public ConfirmPaymentPersonalView(Person owner)
 {
     InitializeComponent();
     ((ObjectDataProvider)this.Resources["Owner"]).ObjectInstance = owner;
 }
Exemplo n.º 5
0
 public void AddPerson(Person person)
 {
     Persons.Add(person);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Used when a person transfers an orderline to himself
 /// </summary>
 public void TransferOrderLine(Person newOwner, OrderLine orderLine)
 {
     if (newOwner.State == States.Checkout && orderLine.Owner.State == States.Checkout)
     {
         orderLine.PayForAll(newOwner);
         //orderLine.TransferOwnerShip(newOwner);
     }
 }
Exemplo n.º 7
0
 public void RemovePerson(Person person)
 {
     Persons.Remove(person);
     OrderLines.RemoveAll(x => x.Owner.Equals(person));
 }
Exemplo n.º 8
0
        /// <summary>
        /// Used when a person wants to remove an item he has ordered
        /// </summary>
        public void RemoveOneOrderedItem(Person person, OrderableItem item)
        {
            OrderLine itemToRemove = OrderLines.FirstOrDefault(x => x.Owner.Equals(person) && x.Item.Equals(item));
            if (itemToRemove != null)
            {
                if (person.State != States.Ordering)
                {
                    person.State = States.Ordering;
                    person.OnPropertyChanged("Status");
                }

                OrderLines.Remove(itemToRemove);
                person.OnPropertyChanged("OrderLines");
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Used when a person wants to pay for everything another person has ordered
        /// </summary>
        public void PayForPerson(Person payer, Person target)
        {
            if (!payer.Equals(target) && target.State == States.Checkout)
            {
                if (payer.State != States.Checkout)
                {
                    payer.State = States.Checkout;
                    payer.OnPropertyChanged("Status");
                }

                foreach (OrderLine line in OrderLines.Where(x => x.Owner.Equals(target)))
                {
                    line.PayForAll(payer);
                }
                payer.OnPropertyChanged("OrderLines");
                target.OnPropertyChanged("OrderLines");
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Used when a person wants to order an item from the menu
        /// </summary>
        public void OrderOneItem(Person person, OrderableItem item)
        {
            if (person.State != States.Ordering)
            {
                person.State = States.Ordering;
                person.OnPropertyChanged("Status");
            }

            OrderLines.Add(new OrderLine(person, item));
            person.OnPropertyChanged("OrderLines");
        }
Exemplo n.º 11
0
 public void NextStateForPerson(Person person)
 {
     States newState = StateMachineHelper.GetNextState(person.State);
     NextStateForPerson(person, newState);
 }
Exemplo n.º 12
0
 /// <summary>
 /// Used when a person pushed the confirm button,
 /// either for confirming an order or a bill
 /// </summary>
 public void NextStateForPerson(Person person, States newState)
 {
     person.State = newState;
     if (Persons.Count(x => x.State.Equals(person.State)) == Persons.Count ||
         (GlobalState == States.Checkout && OrderLines.Count == 0))
     {
         NextGlobalState();
     }
     person.OnPropertyChanged("Status");
 }
Exemplo n.º 13
0
 public Bill(Person owner)
 {
     this.Owner = owner;
     InitializeComponent();
     ((ObjectDataProvider)this.Resources["Owner"]).ObjectInstance = owner;
 }