//[NopHttpsRequirement(SslRequirement.No)] TODO: where is this decoration? public ActionResult AUConsignorProductEmailInquiry(AUConsignorProductEmailInquiryModel model) { //TODO: Build service to capture AUConsignor settings, one of which tells if product inquiries allowed for this store //if (!_forumSettings.AllowPrivateMessages) //{ // return RedirectToRoute("HomePage"); //} //TODO: add same flow to register user before bid can be entered as have for product inquiry //TODO: when cancel out of product emailinquiry need to go back to original product view if (_workContext.CurrentCustomer.IsGuest()) //TODO: Guests can't post product inquiries - don't show button { return new HttpUnauthorizedResult(); } int pmRoleId = _AUcatalogService.GetIdForRole("ProductInquiryMonitor"); int[] customerRoleIds = new int[1]; customerRoleIds[0] = pmRoleId; //this will only find customers with the Product Inquiry Monitor role var pmCustomers = _customerService.GetAllCustomers( customerRoleIds: customerRoleIds, pageIndex: 0, pageSize: 500); //Old way //Customer toCustomer = null; //toCustomer = _customerService.GetCustomerById(model.ToCustomerId); //TODO: need to get the Monitor Product Inquiries role //TODO: GRACEFULLY ERROR IF PRODUCT MONITOR NOT FOUND Customer toCustomer = pmCustomers.FirstOrDefault(); //TODO: Prouct private message can respond back to admin response //TODO: Is Inbox only enabled if forums are enabled?? //TODO: ADD FULL AUDIT ATSYSTEM STARTUP AND VIA BUTTON TO CHECK SHITLOAD OF CONDITIONS //--> Product Monitor not designated and store allows product inquiries //--> more than one product monitor designated //var replyToPM = _forumService.GetPrivateMessageById(model.ReplyToMessageId); //if (replyToPM != null) //{ // if (replyToPM.ToCustomerId == _workContext.CurrentCustomer.Id || replyToPM.FromCustomerId == _workContext.CurrentCustomer.Id) // { // toCustomer = replyToPM.FromCustomer; // } // else // { // return RedirectToRoute("PrivateMessages"); // } //} //else //{ // toCustomer = _customerService.GetCustomerById(model.ToCustomerId); //} //IsGuest found in C:\Users\Nicholas\Documents\My Documents\NopCommerce\Libraries\Nop.Core\Domain\Customers\CustomerExtensions.cs if (toCustomer == null || toCustomer.IsGuest()) { return RedirectToRoute("PrivateMessages"); //TODO: CHANGE THIS REDIRECT? seems to be working if guest; test if not guest but no product monitors } model.ToCustomerId = toCustomer.Id; model.CustomerToName = toCustomer.FormatUserName(); model.AllowViewingToProfile = _customerSettings.AllowViewingProfiles && !toCustomer.IsGuest(); if (ModelState.IsValid) { try { string subject = model.Subject; if (_forumSettings.PMSubjectMaxLength > 0 && subject.Length > _forumSettings.PMSubjectMaxLength) { subject = subject.Substring(0, _forumSettings.PMSubjectMaxLength); } var text = model.Message; if (_forumSettings.PMTextMaxLength > 0 && text.Length > _forumSettings.PMTextMaxLength) { text = text.Substring(0, _forumSettings.PMTextMaxLength); } var nowUtc = DateTime.UtcNow; var privateMessage = new PrivateMessage { StoreId = _storeContext.CurrentStore.Id, ToCustomerId = toCustomer.Id, FromCustomerId = _workContext.CurrentCustomer.Id, Subject = subject, Text = text, IsDeletedByAuthor = false, IsDeletedByRecipient = false, IsRead = false, CreatedOnUtc = nowUtc }; _forumService.InsertPrivateMessage(privateMessage); //activity log _customerActivityService.InsertActivity("PublicStore.SendPM", _localizationService.GetResource("ActivityLog.PublicStore.SendPM"), toCustomer.Email); return RedirectToRoute("PrivateMessages", new { tab = "sent" }); //TODO redirect to product page } catch (Exception ex) { ModelState.AddModelError("", ex.Message); } } return View(model); }
public ActionResult AUConsignorProductEmailInquiry(int productId) { if (_workContext.CurrentCustomer.IsGuest()) //TODO: Guests can't post product inquiries - don't show button { return new HttpUnauthorizedResult(); } //TODO as yet not determined if need Lot info to mail inquiry var product = _productService.GetProductById(productId); //OLD if (product == null || product.Deleted || !product.Published || !_catalogSettings.EmailAFriendEnabled) if (product == null || product.Deleted || !product.Published) //TODO: ADD CONFIG FOR PRODUCT EMAIL INQUIRY return RedirectToRoute("HomePage"); //TODO: redirect to better place var model = new AUConsignorProductEmailInquiryModel(); model.Subject = "Customer II Inquiry about product SKU: " + product.Sku + " " + product.Name; model.ToCustomerId = 1; //TODO - HOW TO GET THE (1) USER WITH MONITOR PRODUCT ROLE //model.ProductId = product.Id; //model.ProductName = product.GetLocalized(x => x.Name); //model.ProductSeName = product.GetSeName(); //model.YourEmailAddress = _workContext.CurrentCustomer.Email; //model.DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnEmailProductToFriendPage; return View(model); }