Example #1
0
 public ManageItemsViewModel()
 {
     using (AppContext context = new AppContext()) {
         context.Items.Load();
         ConvertCollection convert = new ConvertCollection();
         Items = convert.GetItemModelFrom(context.Items.Local);
     }
 }
 public ManageParticipantsViewModel()
 {
     using (AppContext context = new AppContext()) {
         context.Participants.Load();
         ConvertCollection convert = new ConvertCollection();
         Participants = convert.GetParticipantModelFrom(context.Participants.Local);
     }
 }
Example #3
0
 private void AddItem()
 {
     using (AppContext context = new AppContext()) {
         var item = context.Items.Create();
         item.Name = "<Enter Name>";
         item.Description = "<Enter Description>";
         item.Sku = "<Sku>";
         context.Items.Add(item);
         context.SaveChanges();
         var model = new ItemModel(item);
         Items.Add(model);
         SelectedItem = model;
     }
 }
        private void AddParticipant()
        {
            using (AppContext context = new AppContext()) {
                var participant = context.Participants.Create();

                participant.Name = "Update Name";
                participant.Contact = new DomainObjects.Entities.ContactDetails();
                participant.Contact.Address1 = "Update Contact Info";

                context.Participants.Add(participant);
                context.SaveChanges();

                SelectedParticipant = new ParticipantModel(participant);
                Participants.Add(SelectedParticipant);
            }
        }
 private void RefreshSelectedRaffle()
 {
     using (AppContext context = new AppContext()) {
         var dbRaffle = context.Raffles.First(r => r.RaffleId == SelectedRaffle.RaffleId);
         SelectedRaffle.Name = dbRaffle.Name;
         SelectedRaffle.Description = dbRaffle.Description;
         SelectedRaffle.Location = dbRaffle.Location;
     }
 }
 private void UpdateParticipant()
 {
     using (AppContext context = new AppContext()) {
         var participant = context.Participants.First(x => x.ParticipantId == selectedParticipant.ParticipantId);
         context.Entry(participant).CurrentValues.SetValues(SelectedParticipant);
         context.SaveChanges();
     }
 }
 private void RefreshSelectedParticipant()
 {
     using (AppContext context = new AppContext()) {
         var dbParticipant = context.Participants.First(r => r.ParticipantId == SelectedParticipant.ParticipantId);
         SelectedParticipant.Name = dbParticipant.Name;
         SelectedParticipant.Contact = dbParticipant.Contact;
     }
 }
 private void DeleteParticipant()
 {
     if (selectedParticipant != null) {
         using (AppContext context = new AppContext()) {
             var participant = context.Participants.First(x => x.ParticipantId == selectedParticipant.ParticipantId);
             context.Participants.Remove(participant);
             context.SaveChanges();
         }
         Participants.Remove(selectedParticipant);
     }
 }
Example #9
0
 private void UpdateItem()
 {
     using (AppContext context = new AppContext()) {
         var item = context.Items.First(x => x.ItemId == selectedItem.ItemId);
         context.Entry(item).CurrentValues.SetValues(selectedItem);
         context.SaveChanges();
     }
 }
Example #10
0
 private void RefreshSelectedItem()
 {
     using (AppContext context = new AppContext()) {
         var dbItem = context.Items.First(r => r.ItemId == SelectedItem.ItemId);
         SelectedItem.Name = dbItem.Name;
         SelectedItem.Description = dbItem.Description;
         SelectedItem.Sku = dbItem.Sku;
     }
 }
Example #11
0
 private void DeleteItem()
 {
     using (AppContext context = new AppContext()) {
         var item = context.Items.First(x => x.ItemId == selectedItem.ItemId);
         context.Items.Remove(item);
         context.SaveChanges();
     }
     Items.Remove(selectedItem);
 }