Esempio n. 1
0
        private void HandleMessage(MessageService message)
        {
            if(message.EntityState==EntityState.Added)
            {
                var basicSeller = (BasicPersonInformation)message.Seller;
                SellerList.Add(basicSeller);
            }
            if (message.EntityState == EntityState.Edited)
            {
                var oldSeller = SellerList.FirstOrDefault(s => s.PersonId == message.Seller.ID);

                SellerList.Remove(oldSeller);

                var basicSeller = (BasicPersonInformation)message.Seller;

                SellerList.Add(basicSeller);
            }
        }
Esempio n. 2
0
 private void HandlePaymentDetailMessage(MessageService message)
 {
     if (message.PaymentDetail != null)
     {
         PaymentDetailList.Add(message.PaymentDetail);
     }
     if (message.Buyer != null)
     {
         if (message.EntityState == EntityState.Added)
         {
             BuyerList.Add(message.Buyer);
         }
         if (message.EntityState == EntityState.Deleted)
         {
             BuyerList.Remove(message.Buyer);
         }
     }
 }
 private void HandleMessage(MessageService message)
 {
     if (message.EntityState == EntityState.Edit)
     {
         Mode = Mode.Edit;
         ReadFromModel(message.PaymentDetail);
     }
 }
Esempio n. 4
0
        private void AddBuyer(Buyer buyer)
        {
            try
            {
                Context.People.Add(buyer);
                SelectedSeller.Buyers.Add(buyer);
                Context.Complete();

            }
            catch (Exception)
            {
                throw new Exception("Nie udało się stworzyć nabywcy");
            }
            var message = new MessageService(buyer, EntityState.Added);
            Messenger.Default.Send(message, MessengerToken.BuyerListVm);
            Messenger.Default.Send(message, MessengerToken.PaymentVm);
            StatusSetter.SetStatus("Nabywca dodany");
            GoBack();
        }
Esempio n. 5
0
 /// <summary>
 /// Handles message from InvoiceListViewModel. it can contain
 /// invoice to edit that will be loaded to form, otherwise it will
 /// clear properites in form and change to add mode
 /// </summary>
 private void HandleMessage(MessageService message)
 {
     if (message.EntityState == EntityState.Edit)
     {
         Mode = Mode.Edit;
         LoadInvoice(message.Invoice);
     }
     else if (message.EntityState == EntityState.Add)
     {
         ExecuteClearPayment();
     }
     else if (message.EntityState == EntityState.Load)
     {
         Mode = Mode.Add;
         LoadInvoice(message.Invoice);
     }
 }
Esempio n. 6
0
        private void ExecuteDeleteBuyer()
        {
            try
            {
                _context.People.RemoveById(SelectedBuyer.ID);
                _context.Complete();

                BuyerList.Remove(SelectedBuyer);
            }
            catch
            {
                throw new Exception("Nie udało się skasować nabywcy");
            }

            var message = new MessageService(SelectedBuyer, EntityState.Deleted);
            Messenger.Default.Send(message, MessengerToken.PaymentVm);
            StatusSetter.SetStatus("Nabywca usunięty");
            SelectedBuyer = null;
        }