// copy all rows from a List of serialized data objects to a List of SOAP Contracts, // with a limit on number of returned rows and order by columns // links: // docLink: http://sql2x.org/documentationLink/f23c4cd8-e941-4b3e-8fda-7b2ac6a399f7 public List <CrudeServicePackageContract> FetchAllWithLimit(int limit) { var list = new List <CrudeServicePackageContract>(); List <CrudeServicePackageData> dataList = CrudeServicePackageData.FetchAllWithLimit(limit); foreach (CrudeServicePackageData crudeServicePackage in dataList) { var contract = new CrudeServicePackageContract(); DataToContract(crudeServicePackage, contract); list.Add(contract); } return(list); }
// delete a row in table based on primary key // links: // docLink: http://sql2x.org/documentationLink/eb0597e0-8ea0-425c-88af-213a170bbd5e public void Delete(System.Guid servicePackageId) { CrudeServicePackageData.Delete(servicePackageId); }
// get a count of rows in table // links: // docLink: http://sql2x.org/documentationLink/7cd5e52c-b3d7-4566-a27a-408d0732dd88 public int FetchAllCount() { return(CrudeServicePackageData.FetchAllCount()); }
// fetch by Foreign key into new List of class instances // links: // docLink: http://sql2x.org/documentationLink/a7599485-4f00-4ebf-974d-53f69c43654e public List <CrudeServicePackageContract> FetchByArrivalAirportId(System.Guid arrivalAirportId) { return(DataListToContractList(CrudeServicePackageData.FetchByArrivalAirportId(arrivalAirportId))); }
// fetch by Foreign key into new List of class instances // links: // docLink: http://sql2x.org/documentationLink/a7599485-4f00-4ebf-974d-53f69c43654e public List <CrudeServicePackageContract> FetchByUserId(System.Guid userId) { return(DataListToContractList(CrudeServicePackageData.FetchByUserId(userId))); }
// fetch by Search key into current object // links: // crud definition: https://en.wikipedia.org/wiki/Create,_read,_update_and_delete // docLink: http://sql2x.org/documentationLink/87368fa6-b618-4f0c-acbb-1fc4e273bb2d // parameters: // ArrivalAirportId: key of table CrudeServicePackageData public List<CrudeServicePackageModel> FetchByArrivalAirportId(System.Guid arrivalAirportId) { return DataListToModelList(CrudeServicePackageData.FetchByArrivalAirportId(arrivalAirportId)); }
// fetch by Foreign key into new List of class instances // links: // docLink: http://sql2x.org/documentationLink/a7599485-4f00-4ebf-974d-53f69c43654e public List <CrudeServicePackageContract> FetchByDepartureAirportId(System.Guid departureAirportId) { return(DataListToContractList(CrudeServicePackageData.FetchByDepartureAirportId(departureAirportId))); }
// fetch by Search key into current object // links: // crud definition: https://en.wikipedia.org/wiki/Create,_read,_update_and_delete // docLink: http://sql2x.org/documentationLink/87368fa6-b618-4f0c-acbb-1fc4e273bb2d // parameters: // ServiceSpecialServiceRequestId: key of table CrudeServicePackageData public List<CrudeServicePackageModel> FetchByServiceSpecialServiceRequestId(System.Guid serviceSpecialServiceRequestId) { return DataListToModelList(CrudeServicePackageData.FetchByServiceSpecialServiceRequestId(serviceSpecialServiceRequestId)); }
// fetch by Foreign key into new List of class instances // links: // docLink: http://sql2x.org/documentationLink/a7599485-4f00-4ebf-974d-53f69c43654e public List <CrudeServicePackageContract> FetchByServiceSpecialServiceRequestId(System.Guid serviceSpecialServiceRequestId) { return(DataListToContractList(CrudeServicePackageData.FetchByServiceSpecialServiceRequestId(serviceSpecialServiceRequestId))); }
// transfer model to data and update, on a transaction // links: // docLink: http://sql2x.org/documentationLink/aa07e05b-edc8-4e09-bf93-bf2a40c93c09 public void Update(CrudeServicePackageModel model, SqlConnection connection, SqlTransaction transaction) { var data = new CrudeServicePackageData(); ModelToData(model, data); data.Update(connection, transaction); }
// fetch by Search key into current object // links: // crud definition: https://en.wikipedia.org/wiki/Create,_read,_update_and_delete // docLink: http://sql2x.org/documentationLink/87368fa6-b618-4f0c-acbb-1fc4e273bb2d // parameters: // ServiceHotelId: key of table CrudeServicePackageData public List<CrudeServicePackageModel> FetchByServiceHotelId(System.Guid serviceHotelId) { return DataListToModelList(CrudeServicePackageData.FetchByServiceHotelId(serviceHotelId)); }
// transfer model to data and update // links: // docLink: http://sql2x.org/documentationLink/658fda50-2ad3-414e-9299-2b399d17a057 public void Update(CrudeServicePackageModel model) { var data = new CrudeServicePackageData(); ModelToData(model, data); data.Update(); }
// transfer model to data and insert // links: // docLink: http://sql2x.org/documentationLink/17cd8423-3c78-459f-a45b-773fcfbc3b7d public void Insert(CrudeServicePackageModel model) { var data = new CrudeServicePackageData(); ModelToData(model, data); data.Insert(); }
// fetch by Search key into current object // links: // crud definition: https://en.wikipedia.org/wiki/Create,_read,_update_and_delete // docLink: http://sql2x.org/documentationLink/87368fa6-b618-4f0c-acbb-1fc4e273bb2d // parameters: // UserId: key of table CrudeServicePackageData public List<CrudeServicePackageModel> FetchByUserId(System.Guid userId) { return DataListToModelList(CrudeServicePackageData.FetchByUserId(userId)); }
public void PromotionSend( Guid servicePackagePromotionId, Guid userId ) { Logging log = Logging.PerformanceTimeStart( "Service", "BusinessLogicLayer", "ServiceService", "PromotionSend", userId ); using (var connection = new SqlConnection(Conn.ConnectionString)) { connection.Open(); SqlTransaction transaction = connection.BeginTransaction(); try { var promotionData = CrudeServicePackagePromotionData.GetByServicePackagePromotionId(servicePackagePromotionId); var packageData = CrudeServicePackageData.GetByServicePackageId(promotionData.ServicePackageId); var clientData = CrudeClientData.GetByClientId(promotionData.ClientId); var contactData = CrudeClientContactMethodData.GetCurrentMail(promotionData.ClientId); // todo, assume one hit GetServicePackageData packageDetailsData = new ServiceSearch().GetServicePackage(promotionData.ServicePackageId)[0]; string messageText = string.Empty; messageText += "Hi,<br>\r\n"; messageText += "<br>\r\n"; if (!string.IsNullOrEmpty(packageDetailsData.DepartureAirportName)) { messageText += " From: " + packageDetailsData.DepartureAirportName + "<br>\r\n"; } if (!string.IsNullOrEmpty(packageDetailsData.ArrivalAirportName)) { messageText += " To: " + packageDetailsData.ArrivalAirportName + "<br>\r\n"; } if (!string.IsNullOrEmpty(packageDetailsData.CarName)) { messageText += " Traveling with: " + packageDetailsData.CarName + "<br>\r\n"; } if (!string.IsNullOrEmpty(packageDetailsData.HotelName)) { messageText += " Staying at: " + packageDetailsData.HotelName + "<br>\r\n"; } if (!string.IsNullOrEmpty(packageDetailsData.ServiceSpecialServiceRequestName)) { messageText += " Special Request: " + packageDetailsData.ServiceSpecialServiceRequestName + "<br>\r\n"; } List <CrudeDefaultSystemSettingData> systemSettingDatas = CrudeDefaultSystemSettingData.FetchWithFilter( Guid.Empty, DefaultSystemSettingRef.EMailURL, string.Empty, Guid.Empty, DateTime.MinValue ); CrudeDefaultSystemSettingData systemSettingData; if (systemSettingDatas.Count > 0) { systemSettingData = systemSettingDatas[0]; messageText += "<br>\r\n"; messageText += "The package is not yet a booking, click "; // http://localhost:1301/ServicePackagePromotionWithFilter/ServicePackagePromotionMakeBooking?servicePackagePromotionId=4417cd4e-e033-4644-b9fe-74ceec50d903 messageText += "<a href=\"" + systemSettingData.DefaultSystemSettingValue; messageText += "/ServicePackagePromotionWithFilter/ServicePackagePromotionMakeBooking"; messageText += "?servicePackagePromotionId=" + promotionData.ServicePackagePromotionId.ToString(); messageText += "\">here to make it into one</a>. The flight will be the first available one, so fly to the airport :-|<br>\r\n"; // change package message messageText += "If you for some reason do not agree with this wonderful package then <br>\r\n"; messageText += " it can be "; messageText += "<a href=\"" + systemSettingData.DefaultSystemSettingValue; messageText += "/GetServicePackageLive/ServicePackageEdit"; messageText += "?servicePackageId=" + packageData.ServicePackageId.ToString(); messageText += "\">changed here</a><br>\r\n"; // confirmed message messageText += "<br>\r\n"; messageText += "The booking will be confirmed and a new mail message will arrive at this address confirming that fact.<br>\r\n"; messageText += "In the confirmation mail you can view the complete booking through web pages or a windows interface<br>\r\n"; messageText += "<br>\r\n"; messageText += "Thanks for booking through nor-port<br>\r\n"; messageText += "<br>\r\n"; } messageText += "//nor-port<br>\r\n"; SmtpClient client = new SmtpClient(); client.Port = 587; client.Host = "smtp.live.com"; // todo, system setting client.EnableSsl = true; client.Timeout = 10000; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.UseDefaultCredentials = false; // todo, system setting client.Credentials = new System.Net.NetworkCredential( "emailLog", "HU6767Ghvhvj" ); MailMessage message = new MailMessage( "emailLog", contactData.ContactMethodWay, "Promotional Package : " + packageData.ServicePackageName, messageText ); message.IsBodyHtml = true; message.BodyEncoding = UTF8Encoding.UTF8; message.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure; client.Send(message); transaction.Commit(); log.PerformanceTimeStop(); } catch (Exception ex) { transaction.Rollback(); log.Error(ex); throw ex; } } }
// fetch by Foreign key into new List of class instances // links: // docLink: http://sql2x.org/documentationLink/a7599485-4f00-4ebf-974d-53f69c43654e public List <CrudeServicePackageContract> FetchByServiceCarRentalId(System.Guid serviceCarRentalId) { return(DataListToContractList(CrudeServicePackageData.FetchByServiceCarRentalId(serviceCarRentalId))); }
public void PromotionMakeBooking( Guid servicePackagePromotionId, Guid userId ) { Logging log = Logging.PerformanceTimeStart( "Service", "BusinessLogicLayer", "ServiceService", "PromotionMakeBooking", userId ); using (var connection = new SqlConnection(Conn.ConnectionString)) { connection.Open(); SqlTransaction transaction = connection.BeginTransaction(); var promotionData = CrudeServicePackagePromotionData.GetByServicePackagePromotionId(servicePackagePromotionId); var packageData = CrudeServicePackageData.GetByServicePackageId(promotionData.ServicePackageId); var clientData = CrudeClientData.GetByClientId(promotionData.ClientId); var contactData = CrudeClientContactMethodData.GetCurrentMail(promotionData.ClientId); // get flights // make booking var bookingService = new BookingService(); BookingContract booking = bookingService.GetBookingEmpty(userId); // save booking // todo, transaction booking.Booking.BookingId = bookingService.UpdateBooking( booking.Booking.BookingId, booking.Booking.BookingSourceRcd, booking.BookingIdentifier.BookingIdentifierValue, contactData.ContactMethodWay, "PromotionMakeBooking", string.Empty, booking.Booking.FinancialCurrencyId, booking.Booking.FinancialCostcentreId, userId ); // flights if (packageData.DepartureAirportId != Guid.Empty) { Guid flightId = Flight.GetFlightMatching( packageData.DepartureAirportId, packageData.ArrivalAirportId ); if (flightId != Guid.Empty) { bookingService.FlightAdd( booking.Booking.BookingId, flightId, userId ); } } // passengers bookingService.PassengerAdd( booking.Booking.BookingId, PassengerTypeRef.Adult, clientData.FirstName + ' ' + clientData.MiddleName + ' ' + clientData.LastName, userId ); // services (SSR) if (packageData.ServiceSpecialServiceRequestId != Guid.Empty) { bookingService.BookingServiceSpecialServiceRequestAdd( booking.Booking.BookingId, packageData.ServiceSpecialServiceRequestId, userId ); } // services (Hotel) if (packageData.ServiceHotelId != Guid.Empty) { bookingService.BookingServiceHotelAdd( booking.Booking.BookingId, packageData.ServiceHotelId, userId ); } // services (Car) if (packageData.ServiceCarRentalId != Guid.Empty) { bookingService.BookingServiceCarRentalAdd( booking.Booking.BookingId, packageData.ServiceCarRentalId, userId ); } // confirm booking bookingService.BookingConfirm( booking.Booking.BookingId, userId ); try { transaction.Commit(); log.PerformanceTimeStop(); } catch (Exception ex) { transaction.Rollback(); log.Error(ex); throw ex; } } }
// fetch by Search key into current object // links: // crud definition: https://en.wikipedia.org/wiki/Create,_read,_update_and_delete // docLink: http://sql2x.org/documentationLink/87368fa6-b618-4f0c-acbb-1fc4e273bb2d // parameters: // DepartureAirportId: key of table CrudeServicePackageData public List<CrudeServicePackageModel> FetchByDepartureAirportId(System.Guid departureAirportId) { return DataListToModelList(CrudeServicePackageData.FetchByDepartureAirportId(departureAirportId)); }