private void subEventDelete_Click(object sender, RoutedEventArgs e)
        {
            Button        b = (Button)e.Source;
            SubEventModel s = b.DataContext as SubEventModel;

            this._vm.DeleteSubEvent(s);
        }
Esempio n. 2
0
        // Object is not in database and method should return null
        public void getByIDTest2()
        {
            int id = 99;

            SubEvent expected = null;

            SubEvent actual;

            actual = SubEventModel.getByID(id);

            Assert.AreEqual(expected, actual);
        }
        /// <summary>
        /// Adds an empty SubEvent into the list.
        /// </summary>
        public void AddNewSubEvent()
        {
            SubEventModel s = new SubEventModel(new DBLayer.SubEvent());

            s.Name  = "";
            s.Start = new DateTime(DateTime.Now.Year, DateTime.Now.Month, (DateTime.Now.Day + 3), 8, 0, 0);
            s.End   = new DateTime(DateTime.Now.Year, DateTime.Now.Month, (DateTime.Now.Day + 3), 9, 0, 0);

            this._subEventCollection.Add(s);
            this.NotifyPropertyChanged("SubEventCollection");

            s.VenueId = 1;
            this.UpdateCapacityUI();
        }
        /// <summary>
        /// Deletes the specified SubEvent from the list.
        /// </summary>
        /// <param name="s">SubEventModel object to be delted.</param>
        public void DeleteSubEvent(SubEventModel s)
        {
            // SubEvent exists in the database. Remember to delete it later!
            if (s.Id > 0)
            {
                this._subEventsToDeleteList.Add(s);
            }
            this._subEventCollection.Remove(s);
            this.NotifyPropertyChanged("SubEventCollection");

            // If list is empty, add a new one since there must be at least one SubEvent.
            if (this._subEventCollection.Count <= 0)
            {
                this.AddNewSubEvent();
            }
        }
Esempio n. 5
0
        // Method should return the object and not null
        public void getByIDTest()
        {
            int id = 9;

            SubEvent expected = new SubEvent();

            expected.Name    = "Test Event";
            expected.EventId = 2;
            expected.VenueId = 1;

            SubEvent actual;

            actual = SubEventModel.getByID(id);

            Assert.AreEqual(expected.Name, actual.Name);
            Assert.AreEqual(expected.EventId, actual.EventId);
            Assert.AreEqual(expected.VenueId, actual.VenueId);
        }
Esempio n. 6
0
        public void createObjTest()
        {
            SubEvent e = new SubEvent(); // TODO: Initialize to an appropriate value

            e.Id      = 98;
            e.Name    = "Test 3";
            e.EventId = 2;
            e.VenueId = 1;
            e.Start   = new DateTime(2012, 4, 20, 7, 0, 0);
            e.End     = new DateTime(2012, 4, 20, 8, 0, 0);

            SubEvent expected = e; // TODO: Initialize to an appropriate value

            SubEvent actual;

            actual = SubEventModel.createObj(e);
            Assert.AreEqual(expected.Name, actual.Name);
            Assert.AreEqual(expected.EventId, actual.EventId);
            Assert.AreEqual(expected.VenueId, actual.VenueId);
        }
        public void getByIDTest()
        {
            int   id       = 20;
            Event expected = new Event();

            expected.Id          = id;
            expected.Budget      = BudgetModel.getByID(37);
            expected.Capacity    = 50;
            expected.Description = "asdasd";
            expected.End         = new DateTime(2012, 4, 4, 2, 33, 3);
            expected.Start       = new DateTime(2012, 4, 4, 2, 33, 3);
            expected.Guests.Add(StudentModel.getByMatricId("test2"));
            expected.Name            = "Hello World";
            expected.Owner           = StudentModel.getByMatricId("test");
            expected.StudentMatricId = "test";
            expected.SubEvents       = SubEventModel.getAllByEventID(20);
            expected.TimeCreated     = new DateTime(2012, 4, 4, 2, 33, 3);
            expected.ViewAtLoginPage = 1;

            Event actual = EventModel.getByID(id);

            Assert.IsTrue(PropertiesEqual(actual, expected));
        }