Пример #1
0
 public void DeleteAppointment(Appointment appointment)
 {
     using (var ctx = new SystemContext())
     {
         ctx.Appointments.Attach(appointment);
         ctx.Appointments.Remove(appointment);
         ctx.SaveChanges();
     }
 }
Пример #2
0
        public void UpdateAppointment(Appointment appointment, DateTime date, DateTime StartTime, DateTime EndTime,
            string category, string descricption, string status)
        {
            appointment.Date = date;
            appointment.StarTime = StartTime;
            appointment.EndTime = EndTime;
            appointment.Category = category;
            appointment.Description = descricption;
            appointment.Status = status;

            using (var ctx = new SystemContext())
            {
                ctx.Entry(appointment).State = System.Data.Entity.EntityState.Modified;
                ctx.SaveChanges();
            }
        }
Пример #3
0
 public void InsertAppointment(Appointment appointment, Buyer buyer, Seller seller)
 {
     using (var ctx = new SystemContext())
     {
         ctx.Appointments.Add(appointment);
         if (buyer != null)
         {
             ctx.Buyers.Attach(buyer);
             appointment.Buyer = buyer;
         }
         if (seller != null)
         {
             ctx.Sellers.Attach(seller);
             appointment.Seller = seller;
         }
         ctx.SaveChanges();
     }
 }
Пример #4
0
        public void CreateTest()
        {
            //Creating properties for the Appointment
            DateTime date = DateTime.Today;
            DateTime meetingStart = DateTime.Now;
            DateTime meetingEnd = DateTime.Now.AddHours(2);

            //Create the Appointment itself
            Appointment testAppointment = new Appointment() { Date = date, StarTime = meetingStart, EndTime = meetingEnd, Category = "Sælgermøde", Description = "Test for at finde en appointment", Status = "Status", UserID = 1 };

            //Save it to the database
            int CountDB = aCtr.GetAllAppointments().ToList().Count;
            aCtr.InsertAppointment(testAppointment, null, null);
            int CountDBAfter = aCtr.GetAllAppointments().ToList().Count;

            //Compare Properties. Maybe use conditions other than Adress?
            Assert.AreEqual<int>(CountDBAfter, CountDB + 1);
            aCtr.DeleteAppointment(testAppointment); ;
        }
Пример #5
0
        public void DeleteTest()
        {
            //Creating properties for the Appointment
            DateTime date = DateTime.Today;
            DateTime meetingStart = DateTime.Now;
            DateTime meetingEnd = DateTime.Now.AddHours(2);

            //Create the Appointment itself
            Appointment testAppointment = new Appointment() { Date = date, StarTime = meetingStart, EndTime = meetingEnd, Category = "Sælgermøde", Description = "Test for at finde en appointment", Status = "Status", UserID = 1 };

            //Save it to the database
            aCtr.InsertAppointment(testAppointment, null, null);

            //Delete it again
            aCtr.DeleteAppointment(testAppointment);

            //Try to retrieve the deleted Appointment again, and assert it is null.
            Appointment testAppointmentDB = aCtr.GetAppointment(date).SingleOrDefault();
            Assert.AreEqual(null, testAppointmentDB);
        }
Пример #6
0
        public void ReadTest()
        {
            //Creating properties for the Appointment
            DateTime date = DateTime.Today;
            DateTime meetingStart = DateTime.Now;
            DateTime meetingEnd = DateTime.Now.AddHours(2);

            //Create the Appointment itself
            Appointment testAppointment = new Appointment() { Date = date, StarTime = meetingStart, EndTime = meetingEnd, Category = "Sælgermøde", Description = "Test for at finde en appointment", Status = "Status", UserID = 1 };

            //Save it to the database
            aCtr.InsertAppointment(testAppointment, null, null);

            //Get property from database and assert not null
            Assert.IsNotNull(aCtr.GetAppointment(date));
            aCtr.DeleteAppointment(testAppointment);
        }
Пример #7
0
        public void UpdateTest()
        {
            //Creating properties for the Appointment
            DateTime date = DateTime.Today;
            DateTime meetingStart = DateTime.Now;
            DateTime meetingEnd = DateTime.Now.AddHours(2);

            //Create the Appointment itself
            Appointment testAppointment = new Appointment() { Date = date, StarTime = meetingStart, EndTime = meetingEnd, Category = "Sælgermøde", Description = "Test for at finde en appointment", Status = "Status", UserID = 1 };

            //Save it to the database
            aCtr.InsertAppointment(testAppointment, null, null);

            //Change the Appointment:

            aCtr.UpdateAppointment(testAppointment, date, meetingStart, meetingEnd, "Ny", "Hej", "done", null, null);

            //Test the assertion
            Assert.AreNotEqual<string>("Sælgermøde", aCtr.GetAppointment(date).First().Category);
            aCtr.DeleteAppointment(testAppointment);
        }
Пример #8
0
 public void UpdateAppointment(Appointment appointment, DateTime date, DateTime StartTime, DateTime EndTime, 
     string category, string descricption, string status)
 {
     dbApp.UpdateAppointment(appointment, date, StartTime, EndTime, category, descricption, status);
 }
Пример #9
0
 public void InsertAppointment(Appointment appointment, Buyer buyer, Seller seller)
 {
     dbApp.InsertAppointment(appointment, buyer, seller);
 }
Пример #10
0
 public void DeleteAppointment(Appointment appointment)
 {
     dbApp.DeleteAppointment(appointment);
 }