/// <summary> /// Saves a business' Custom Document Text to the Database /// </summary> /// <param name="text">Document Text Dto (must have a businessId included)</param> public void SaveDocumentText(BusinessDocumentText text) { var business = businessDao.GetByKey(text.BusinessId); if (string.IsNullOrWhiteSpace(text.CultureCode)) { text.CultureCode = "root"; } var confirmation = GetBusinessDictionaryInstance(text.Confirmation, text.CultureCode, DictionaryConstants.GUESTMESSAGE_CONFIRMATION, text.BusinessId); var cancellation = GetBusinessDictionaryInstance(text.Cancellation, text.CultureCode, DictionaryConstants.GUESTMESSAGE_CANCELLATION, text.BusinessId); var invoice = GetBusinessDictionaryInstance(text.Invoice, text.CultureCode, DictionaryConstants.GUESTMESSAGE_INVOICE, text.BusinessId); var guestRegistration = GetBusinessDictionaryInstance(text.GuestRegistration, text.CultureCode, DictionaryConstants.GUESTMESSAGE_GUESTREGISTRATION, text.BusinessId); using (var btx = new BusinessTransaction()) { dictionaryManager.UpsertDictionaryInstance(confirmation, true); dictionaryManager.UpsertDictionaryInstance(cancellation, true); dictionaryManager.UpsertDictionaryInstance(invoice, true); dictionaryManager.UpsertDictionaryInstance(guestRegistration, true); business.GuestMessageCancellationId = cancellation.ItemId; business.GuestMessageConfirmationId = confirmation.ItemId; business.GuestMessageGuestRegistrationId = guestRegistration.ItemId; business.GuestMessageInvoiceId = invoice.ItemId; businessDao.Modify(business); eventTrackingManager.CreateBusinessEventAsync(text.BusinessId, BusinessEventTypesEnum.BusinessDocumentTextModified, BusinessEventTypesEnum.BusinessDocumentTextModified.GetCode()); btx.Commit(); } }
/// <summary> /// Loads a business' Custom Document Text from the Database /// </summary> /// <param name="businessId">business Id</param> /// <param name="culture">The culture in which the Document Text should be retrieved by default all document data is stored at root for now</param> /// <returns>Custom Business Document Text</returns> public BusinessDocumentText GetDocumentTextByBusiness(long businessId, string culture = "root") { var results = dictionaryManager.GetDictionaryItemByKeysAndCultures(new List<string> { DictionaryConstants.GUESTMESSAGE + businessId + DictionaryConstants.GUESTMESSAGE_CANCELLATION, DictionaryConstants.GUESTMESSAGE + businessId + DictionaryConstants.GUESTMESSAGE_CONFIRMATION, DictionaryConstants.GUESTMESSAGE + businessId + DictionaryConstants.GUESTMESSAGE_GUESTREGISTRATION, DictionaryConstants.GUESTMESSAGE + businessId + DictionaryConstants.GUESTMESSAGE_INVOICE }, new List<string> { culture }); var text = new BusinessDocumentText { BusinessId = businessId, Cancellation = dictionaryManager.DictionaryItemsToContent(results, DictionaryConstants.GUESTMESSAGE + businessId + DictionaryConstants.GUESTMESSAGE_CANCELLATION), Confirmation = dictionaryManager.DictionaryItemsToContent(results, DictionaryConstants.GUESTMESSAGE + businessId + DictionaryConstants.GUESTMESSAGE_CONFIRMATION), Invoice = dictionaryManager.DictionaryItemsToContent(results, DictionaryConstants.GUESTMESSAGE + businessId + DictionaryConstants.GUESTMESSAGE_INVOICE), GuestRegistration = dictionaryManager.DictionaryItemsToContent(results, DictionaryConstants.GUESTMESSAGE + businessId + DictionaryConstants.GUESTMESSAGE_GUESTREGISTRATION), CultureCode = culture }; return text; }
/// <summary> /// Convert Business.BusinessCustomText to BusinessCustomTextDto /// </summary> /// <param name="text">Business.BusinessCustomText object</param> /// <returns>BusinessCustomTextDto object</returns> public static BusinessDocumentTextDto ConvertToBusinessCustomTextDto(BusinessDocumentText text) { return text != null ? new BusinessDocumentTextDto { BusinessId = text.BusinessId, Cancellation = text.Cancellation, Confirmation = text.Confirmation, GuestRegistration = text.GuestRegistration, Invoice = text.Invoice, CultureCode = text.CultureCode } : null; }