Ejemplo n.º 1
0
 public SampleDataHappening(int happeningId, string happeningName, int maxParticipants, string location, SampleDataUser user)
 {
     this.HappeningId = happeningId;
     this.HappeningName = happeningName;
     this.MaxParticipants = maxParticipants;
     this.Location = location;
     this.User = user;
     this.Tickets = new ObservableCollection<SampleDataTicket>();
 }
Ejemplo n.º 2
0
        private async Task GetSampleDataAsync()
        {
            if (this._groups.Count != 0)
                return;

            Uri dataUri = new Uri("ms-appx:///DataModel/SampleData.json");

            StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(dataUri);
            string jsonText = await FileIO.ReadTextAsync(file);
            JsonObject jsonObject = JsonObject.Parse(jsonText);
            JsonArray jsonArray = jsonObject["Groups"].GetArray();

            foreach (JsonValue groupValue in jsonArray)
            {
                JsonObject groupObject = groupValue.GetObject();
                SampleDataGroup group = new SampleDataGroup(groupObject["UniqueId"].GetString(),
                                                            groupObject["Title"].GetString(),
                                                            groupObject["Subtitle"].GetString(),
                                                            groupObject["ImagePath"].GetString(),
                                                            groupObject["Description"].GetString());

                foreach (JsonValue itemValue in groupObject["Items"].GetArray())
                {
                    JsonObject itemObject = itemValue.GetObject();
                    group.Items.Add(new SampleDataItem(itemObject["UniqueId"].GetString(),
                                                       itemObject["Title"].GetString(),
                                                       itemObject["Subtitle"].GetString(),
                                                       itemObject["ImagePath"].GetString(),
                                                       itemObject["Description"].GetString(),
                                                       itemObject["Content"].GetString()));
                }
                this.Groups.Add(group);
            }

            JsonArray userArray = jsonObject["Groups"].GetArray();
            foreach (JsonValue item in userArray)
            {
                JsonObject userObject = item.GetObject();
                SampleDataUser user = new SampleDataUser(userObject["UserName"].GetString(),
                                                         userObject["FirstName"].GetString(),
                                                         userObject["LastName"].GetString(),
                                                   (int) userObject["AccessLevel"].GetNumber(),
                                                         userObject["Password"].GetString());
                this.Users.Add(user);
            }

            // we make a few instances of our classes for test data

            var sampleUser = new SampleDataUser("nickern" ,"Nicolai", "Naglestad", 1, "123456789");
            this.Users.Add(sampleUser);
            var sampleUser2 = new SampleDataUser("ola" ,"Ola", "Nordmann", 1, "987654321");
            this.Users.Add(sampleUser2);

            var happening = new SampleDataHappening(1, "Neon Party", 200, "Halden", sampleUser);
            this.Happenings.Add(happening);
            var happening2 = new SampleDataHappening(1, "Test Party", 100, "Fredrikstad", sampleUser2);
            this.Happenings.Add(happening2);

            var ticket = new SampleDataTicket("abcdef123456", happening, sampleUser, false, new DateTime(0));
            this.Tickets.Add(ticket);
            var ticket2 = new SampleDataTicket("123456789", happening2, sampleUser, false, new DateTime(0));
            this.Tickets.Add(ticket2);

            var ticket3 = new SampleDataTicket("987654321", happening, sampleUser, true, new DateTime(2015, 11, 12, 15, 25, 00));
            this.Tickets.Add(ticket3);
            var ticket4 = new SampleDataTicket("147258369", happening2, sampleUser, true, new DateTime(2015, 11, 12, 17, 25, 00));
            this.Tickets.Add(ticket4);

        }
Ejemplo n.º 3
0
 public SampleDataTicket(string uniqueId, SampleDataHappening happening, SampleDataUser user, bool scanned, DateTime timeScanned)
 {
     this.UniqueId = uniqueId;
     this.Happening = happening;
     this.User = user;
     this.Scanned = scanned;
     this.TimeScanned = timeScanned;
     this.TimeSold = new DateTime();
 }