public void DeleteAppointment(Appointment appointment) { using (var ctx = new SystemContext()) { ctx.Appointments.Attach(appointment); ctx.Appointments.Remove(appointment); ctx.SaveChanges(); } }
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(); } }
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(); } }
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); ; }
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); }
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); }
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); }
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); }
public void InsertAppointment(Appointment appointment, Buyer buyer, Seller seller) { dbApp.InsertAppointment(appointment, buyer, seller); }
public void DeleteAppointment(Appointment appointment) { dbApp.DeleteAppointment(appointment); }