public async Task Delete_existing_booking_successful() { // Act var actual = await _repository.Delete("goodtoken1"); var expected = OK; // Assert Assert.Equal(expected, actual); }
public void TestBookingRepository() { var booking = new Booking { Id = 1, ClientId = 1, RideId = 1, SeatNo = 10 }; Assert.AreEqual(0, BookingRepository.Size()); try { BookingRepository.Save(booking); } catch { Assert.Fail(); } Assert.AreEqual(1, BookingRepository.Size()); var updateBooking = new Booking { Id = 1, ClientId = 5, RideId = 5, SeatNo = 5 }; try { BookingRepository.Update(booking.Id, updateBooking); } catch { Assert.Fail(); } try { BookingRepository.FindOne(booking.Id); Assert.Fail(); } catch { try { Assert.AreEqual(5, BookingRepository.FindOne(booking.Id).RideId); } catch { Assert.Fail(); } } BookingRepository.Delete(updateBooking.Id); Assert.AreEqual(0, BookingRepository.Size()); }
public void DeleteBooking() { foreach (var cur in repo.GetList(p => p.HomeId == (int)ctx.HomeSet.FirstOrDefault(x => x.Title == "LaCorderie").ClientId)) { List <int> dinnerBookingId = ctx.DinnerBookingSet.Include("Booking").Where(p => p.Booking.Id == cur.Id).Select(p => p.Id).ToList(); List <int> roomBookingId = ctx.RoomBookingSet.Include("Booking").Where(p => p.Booking.Id == cur.Id).Select(p => p.Id).ToList(); repo.Delete(cur); repo.Save(); Assert.AreEqual(0, ctx.AdditionnalBookingSet.Include("Booking").Where(p => p.Booking.Id == cur.Id).ToList().Count); Assert.AreEqual(0, ctx.BillSet.Include("Booking").Where(p => p.Booking.Id == cur.Id).ToList().Count); Assert.AreEqual(0, ctx.BookingDocumentSet.Include("Booking").Where(p => p.Booking.Id == cur.Id).ToList().Count); Assert.AreEqual(0, ctx.BookingStepBookingSet.Where(p => p.Id == cur.Id).ToList().Count); Assert.AreEqual(0, ctx.DepositSet.Include("Booking").Where(p => p.Booking.Id == cur.Id).ToList().Count); Assert.AreEqual(0, ctx.DinnerBookingSet.Include("Booking").Where(p => p.Booking.Id == cur.Id).ToList().Count); foreach (var curdinner in dinnerBookingId) { Assert.AreEqual(0, ctx.MealBookingSet.Include("DinnerBooking").Where(p => p.DinnerBooking.Id == curdinner).ToList().Count); } foreach (var curroom in roomBookingId) { Assert.AreEqual(0, ctx.PeopleBookingSet.Include("RoomBooking").Where(p => p.RoomBooking.Id == curroom).ToList().Count); Assert.AreEqual(0, ctx.SupplementRoomBookingSet.Include("RoomBooking").Where(p => p.RoomBooking.Id == curroom).ToList().Count); } Assert.AreEqual(0, ctx.ProductBookingSet.Include("Booking").Where(p => p.Booking.Id == cur.Id).ToList().Count); Assert.AreEqual(0, ctx.RoomBookingSet.Include("Booking").Where(p => p.Booking.Id == cur.Id).ToList().Count); } }
public void DeleteBooking(int BookingID) { try { BookingRepository bookingRepo = new BookingRepository(); var b = bookingRepo.Get(BookingID); bookingRepo.Delete(b); GlobalUnitOfWork.Commit(); } catch (Exception ex) { throw ex; } }
public async Task <bool> DeleteAsync(long id) { var existedBooking = await _bookingRepository.GetAsync(id); if (existedBooking == null) { throw new Exception($"Booking with id {id} does not exist"); } _bookingRepository.Delete(existedBooking); await _bookingRepository.SaveChangesAsync(); return(await _bookingRepository.SaveChangesAsync()); }
public void DeleteSavedBooking(int id) { using (var emailrepo = new EmailRepository()) { var em = new BookingRepository().GetById(id); List <MailAddress> l = new List <MailAddress>(); MailMessage mail = new MailMessage(); mail.To.Add(new MailAddress(em.Email)); mail.From = new MailAddress("*****@*****.**"); //mail.CC.Add(new MailAddress("*****@*****.**")); //mail.Bcc.Add(new MailAddress("*****@*****.**")); mail.Subject = "Appointment with the Doctor"; string Body = "Dear " + em.PatientFullName + " your appointment to see the doctor on the " + em.Time_start.Substring(0, 10) + " from " + em.Time_start.Substring(10) + " to " + em.Time_end.Substring(10) + " has been canceled"; mail.Body = Body; mail.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); #region configurations is in the web.config //smtp.Host = "localhost";//"smtp.live.com"; //// smtp.Host = "smtp.live.com"; //smtp.Port = 25; //587; //// smtp.Port=587; #endregion smtp.Host = "smtp.sendgrid.net"; smtp.Port = 2525; smtp.UseDefaultCredentials = false; smtp.EnableSsl = true; smtp.Credentials = new System.Net.NetworkCredential("bigiayomide", "123adenike");// enter seders user name and password smtp.Send(mail); using (var bookpro = new BookingRepository()) { Booking _booking = bookpro.GetById(id); bookpro.Delete(_booking); } } }
public void TestDelete() { Booking testBooking = new Booking() { Id = 1, Accommodation = null, AccommodationId = 1, BookingHistory = null, CheckIn = DateTime.Now, CheckOut = DateTime.Now.AddDays(3), GuestId = 2, Guests = new List <Guest>(), HeadGuest = null, TotalPrice = 35 }; List <Booking> bookingsList = new List <Booking>() { new Booking() { Id = 2, Accommodation = null, AccommodationId = 1, BookingHistory = null, CheckIn = DateTime.Now, CheckOut = DateTime.Now.AddDays(7), GuestId = 6, Guests = new List <Guest>(), HeadGuest = null, TotalPrice = 142 }, }; bookingsList.Add(testBooking); bookingsList.ForEach(r => _context.Add(r)); _context.SaveChanges(); var repository = new BookingRepository(_context); repository.Delete(testBooking); Assert.IsNull(_context.Bookings.Find(1)); }
public override bool Delete(BookingModel entity) { var mapper = new MapperConfiguration(c => c.CreateMap <BookingModel, Booking>()).CreateMapper(); return(_repository.Delete(mapper.Map <BookingModel, Booking>(entity))); }
public int Delete(int id) { return(repo.Delete(id)); }