/// <summary> /// ctor the Mighty /// </summary> public SendToShopInProgressMessage(SendToShopOrder sendToShopOrder, Partner partner, PartnerSendToShopSettings partnerSendToShopSettings, IWebSettings webSettings) { this.SendToShopOrder = sendToShopOrder; this.Partner = partner; this.PartnerSendToShopSettings = partnerSendToShopSettings; this.FormatAsHtml = false; this.ToRecipients.Add(sendToShopOrder.EmailAddress); this.Subject = "IN-PROGRESS: Send-To-Shop Order #: " + sendToShopOrder.SendToShopOrderId; this.SenderAddress = webSettings.SenderAddress; this.SenderDisplayName = webSettings.SenderDisplayName; }
/// <summary> /// ctor the Mighty /// </summary> public SendToShopOnHoldMessage(SendToShopOrder sendToShopOrder, Partner partner, PartnerSendToShopSettings partnerSendToShopSettings, IWebSettings webSettings) { this.SendToShopOrder = sendToShopOrder; this.Partner = partner; this.PartnerSendToShopSettings = partnerSendToShopSettings; this.FormatAsHtml = false; this.ToRecipients.Add(sendToShopOrder.EmailAddress); this.Subject = "ON-HOLD: Send-To-Shop Order #: " + sendToShopOrder.SendToShopOrderId; this.SenderAddress = webSettings.SenderAddress; this.SenderDisplayName = webSettings.SenderDisplayName; }
/// <summary> /// ctor the Mighty /// </summary> public SendToShopCancellationMessage(SendToShopOrder sendToShopOrder, Partner partner, PartnerSendToShopSettings partnerSendToShopSettings, IWebSettings webSettings) { this.SendToShopOrder = sendToShopOrder; this.Partner = partner; this.PartnerSendToShopSettings = partnerSendToShopSettings; this.WebSettings = webSettings; this.FormatAsHtml = false; this.ToRecipients.Add(sendToShopOrder.EmailAddress); this.Subject = "CANCELLED: Send-To-Shop Order #: " + sendToShopOrder.SendToShopOrderId; this.SenderAddress = webSettings.SenderAddress; this.SenderDisplayName = webSettings.SenderDisplayName; }
/// <summary> /// ctor the Mighty /// </summary> public SendToShopOrderPartnerNotificationMessage(Partner partner, PartnerSendToShopSettings partnerSendToShopSettings, SendToShopOrder sendToShopOrder, User user, IStringCryptoService stringCryptoService, IWebSettings webSettings, IRecipeDataService recipeDataService) { this.Partner = partner; this.SendToShopOrder = sendToShopOrder; this.User = user; this.StringCryptoService = stringCryptoService; this.WebSettings = webSettings; this.Ingredients = recipeDataService.GetAllPublicIngredients(); // Message Setup this.FormatAsHtml = true; this.Subject = "Brewgr.com - Send-To-Shop Order #:" + sendToShopOrder.SendToShopOrderId; this.SenderAddress = webSettings.SenderAddress; this.SenderDisplayName = webSettings.SenderDisplayName; this.ToRecipients.Add(partnerSendToShopSettings.DeliveryEmailAddress); }
/// <summary> /// Makes one or more email messages for a send to shop order /// </summary> public IList<IEmailMessage> Make(SendToShopOrder sendToShopOrder) { if (sendToShopOrder == null) { throw new ArgumentNullException("sendToShopOrder"); } var user = this.UserService.GetUserById(sendToShopOrder.UserId); if (user == null) { throw new NotSupportedException("Could not locate user for ID=" + sendToShopOrder.UserId); } var partner = this.PartnerService.GetPartnerById(sendToShopOrder.PartnerId); if (partner == null) { throw new NotSupportedException("Could not locate partner for ID=" + sendToShopOrder.PartnerId); } var partnerSendToShopSettings = this.PartnerService.GetPartnerSendToShopSettings(sendToShopOrder.PartnerId); if (partnerSendToShopSettings == null) { throw new NotSupportedException("There are no Send-To-Shop settings for the provided Partner"); } var messages = new List<IEmailMessage>(); switch ((SendToShopOrderStatus)sendToShopOrder.SendToShopOrderStatusId) { case SendToShopOrderStatus.Cancelled: messages.Add(new SendToShopCancellationMessage(sendToShopOrder, partner, partnerSendToShopSettings, this.WebSettings)); break; case SendToShopOrderStatus.Created: // Shop Notification messages.Add(new SendToShopOrderPartnerNotificationMessage(partner, partnerSendToShopSettings, sendToShopOrder, user, this.StringCryptoService, this.WebSettings, this.RecipeDataService)); // User Confirmation messages.Add(new SendToShopConfirmationMessage(sendToShopOrder, partner, partnerSendToShopSettings, this.WebSettings)); break; case SendToShopOrderStatus.OnHold: messages.Add(new SendToShopOnHoldMessage(sendToShopOrder, partner, partnerSendToShopSettings, this.WebSettings)); break; case SendToShopOrderStatus.InProgress: messages.Add(new SendToShopInProgressMessage(sendToShopOrder, partner, partnerSendToShopSettings, this.WebSettings)); break; case SendToShopOrderStatus.ReadyForPickup: messages.Add(new SendToShopReadyMessage(sendToShopOrder, partner, partnerSendToShopSettings, this.WebSettings)); break; default: throw new NotSupportedException("No Message available for this status level"); } return messages; }
/// <summary> /// Makes one or more email messages for a send to shop order /// </summary> public IList <IEmailMessage> Make(SendToShopOrder sendToShopOrder) { if (sendToShopOrder == null) { throw new ArgumentNullException("sendToShopOrder"); } var user = this.UserService.GetUserById(sendToShopOrder.UserId); if (user == null) { throw new NotSupportedException("Could not locate user for ID=" + sendToShopOrder.UserId); } var partner = this.PartnerService.GetPartnerById(sendToShopOrder.PartnerId); if (partner == null) { throw new NotSupportedException("Could not locate partner for ID=" + sendToShopOrder.PartnerId); } var partnerSendToShopSettings = this.PartnerService.GetPartnerSendToShopSettings(sendToShopOrder.PartnerId); if (partnerSendToShopSettings == null) { throw new NotSupportedException("There are no Send-To-Shop settings for the provided Partner"); } var messages = new List <IEmailMessage>(); switch ((SendToShopOrderStatus)sendToShopOrder.SendToShopOrderStatusId) { case SendToShopOrderStatus.Cancelled: messages.Add(new SendToShopCancellationMessage(sendToShopOrder, partner, partnerSendToShopSettings, this.WebSettings)); break; case SendToShopOrderStatus.Created: // Shop Notification messages.Add(new SendToShopOrderPartnerNotificationMessage(partner, partnerSendToShopSettings, sendToShopOrder, user, this.StringCryptoService, this.WebSettings, this.RecipeDataService)); // User Confirmation messages.Add(new SendToShopConfirmationMessage(sendToShopOrder, partner, partnerSendToShopSettings, this.WebSettings)); break; case SendToShopOrderStatus.OnHold: messages.Add(new SendToShopOnHoldMessage(sendToShopOrder, partner, partnerSendToShopSettings, this.WebSettings)); break; case SendToShopOrderStatus.InProgress: messages.Add(new SendToShopInProgressMessage(sendToShopOrder, partner, partnerSendToShopSettings, this.WebSettings)); break; case SendToShopOrderStatus.ReadyForPickup: messages.Add(new SendToShopReadyMessage(sendToShopOrder, partner, partnerSendToShopSettings, this.WebSettings)); break; default: throw new NotSupportedException("No Message available for this status level"); } return(messages); }
/// <summary> /// Places a send to shop order /// </summary> public void PlaceOrder(SendToShopOrder sendToShopOrder) { if(sendToShopOrder == null) { throw new ArgumentNullException("sendToShopOrder"); } var partnerId = this.PartnerIdResolver.Resolve(); if(partnerId == null) { throw new NotSupportedException("Partner Id is required to create a Send-To-Shop Order"); } sendToShopOrder.SendToShopOrderStatusId = (int)SendToShopOrderStatus.Created; sendToShopOrder.PartnerId = partnerId.Value; sendToShopOrder.DateCreated = DateTime.Now; this.Repository.Add(sendToShopOrder); }