/// <summary> /// Updates the booking office. /// </summary> /// <param name="from">From.</param> /// <param name="to">To.</param> public static void UpdateBookingOffice(BookingOffice from, ref BookingOffice to) { to.AddressLine1 = from.AddressLine1; to.AddressLine2 = from.AddressLine2; to.Area = from.Area; to.Email = from.Email; to.PrimaryContact = from.PrimaryContact; to.SecondaryContact = from.SecondaryContact; to.Active = from.Active; }
/// <summary> /// Updates the booking office. /// </summary> /// <param name="bookingOffice">The booking office.</param> public BookingOffice UpdateBookingOffice(BookingOffice bookingOffice) { var existingBookingOffice = this.GetBookingOffice(bookingOffice.Id); if (existingBookingOffice != null) { DataModelUpdater.UpdateBookingOffice(bookingOffice, ref existingBookingOffice); this.context.BookingOffices.Update(existingBookingOffice); this.context.SaveChanges(); } return(existingBookingOffice); }
public void TestBookingOffices() { var databaseService = this.container.Resolve <IDatabaseService>(); var destination = new Destination { City = "Test Location 1", State = "Test Location 1", PostCode = 1000, Active = true }; destination = databaseService.CreateDestination(destination); var bookingOffice1 = new BookingOffice { AddressLine1 = "100 Magbazar Road", Area = "Magbazar", DestinationId = destination.Id, Email = "*****@*****.**", PrimaryContact = "01711665223", Active = true }; bookingOffice1 = databaseService.CreateBookingOffice(bookingOffice1); var bookingOffice2 = new BookingOffice { AddressLine1 = "5 Mirpur Road", Area = "Mirpur 1", DestinationId = destination.Id, Email = "*****@*****.**", PrimaryContact = "01711335223", Active = true }; bookingOffice2 = databaseService.CreateBookingOffice(bookingOffice2); var newBookingOffice1 = databaseService.GetBookingOffice(bookingOffice1.Id); Assert.IsTrue(newBookingOffice1 != null); Assert.AreEqual(newBookingOffice1.AddressLine1, bookingOffice1.AddressLine1); Assert.AreEqual(newBookingOffice1.Area, bookingOffice1.Area); Assert.AreEqual(newBookingOffice1.SecondaryContact, null); newBookingOffice1.Email = "*****@*****.**"; newBookingOffice1.PrimaryContact = "0178822334"; newBookingOffice1.SecondaryContact = "0165515521"; databaseService.UpdateBookingOffice(newBookingOffice1); var updatedBookingOffice1 = databaseService.GetBookingOffice(newBookingOffice1.Id); Assert.IsTrue(updatedBookingOffice1 != null); Assert.AreEqual(updatedBookingOffice1.Email, newBookingOffice1.Email); Assert.AreEqual(updatedBookingOffice1.PrimaryContact, newBookingOffice1.PrimaryContact); Assert.AreEqual(updatedBookingOffice1.SecondaryContact, newBookingOffice1.SecondaryContact); databaseService.DeleteBookingOffice(bookingOffice1.Id); databaseService.DeleteBookingOffice(bookingOffice2.Id); Assert.AreEqual(databaseService.GetBookingOffice(bookingOffice1.Id), null); Assert.AreEqual(databaseService.GetBookingOffice(newBookingOffice1.Id), null); Assert.AreEqual(databaseService.GetBookingOffice(updatedBookingOffice1.Id), null); Assert.AreEqual(databaseService.GetBookingOffice(bookingOffice2.Id), null); databaseService.DeleteDestination(destination.Id); }
/// <summary> /// Creates the bookingOffice. /// </summary> /// <param name="bookingOffice">The booking office.</param> /// <returns>The new booking office identifier.</returns> public BookingOffice CreateBookingOffice(BookingOffice bookingOffice) { this.context.BookingOffices.Add(bookingOffice); this.context.SaveChanges(); return(bookingOffice); }