/// <summary> /// Receives search criteria parameters (key/value pair) and returns a list of matching Subscribers /// </summary> /// <param name="input"></param> /// <returns></returns> public Dtos.GetQuotesResults SendQuote(Dtos.GetQuotesInput input) { Dtos.GetQuotesResults returnResults = new Dtos.GetQuotesResults(); try { Logger.ErrorFormat("CH000:START"); //Get get Subscriber details var subscriber = _subscriberRepository.Get(input.SubscriberRefId); //Get the Request details var request = _requestRepository.Get(input.RequestRefId); //Save Quote var quote = new Quote { Cost = input.Cost, Message = input.Message, RequestRefId = request.Id, SubscriberRefId = subscriber.Id }; Logger.ErrorFormat("CH000:START2"); //Saving entity with standard Insert method of repositories. int quotesId = _quoteRepository.InsertAndGetId(quote); //Update Subscriber Credits var subscriberCredits = new SubscriberCredits() { SubscriberRefId = input.SubscriberRefId, Credits = input.TotalCredits * -1 }; Logger.ErrorFormat("CH000:START3"); int subscriberCreditsResponse = _subscriberCreditsRepository.InsertAndGetId(subscriberCredits); //Get Company Configuration Logger.ErrorFormat("CH000:START4"); var companyConfig = _companyConfigRepository.GetCompanyConfigurations(input.CompanyId); string emailFrom = companyConfig.Find(cc => cc.Name.Equals(System.Configuration.ConfigurationSettings.AppSettings["creditsHero:EmailReply"])).Value != null ? companyConfig.Find(cc => cc.Name.Equals(System.Configuration.ConfigurationSettings.AppSettings["creditsHero:EmailReply"])).Value : "*****@*****.**"; string emailSubject = companyConfig.Find(cc => cc.Name.Equals(System.Configuration.ConfigurationSettings.AppSettings["creditsHero:EmailSubject"])).Value != null ? companyConfig.Find(cc => cc.Name.Equals(System.Configuration.ConfigurationSettings.AppSettings["creditsHero:EmailSubject"])).Value : "Vendor Quote"; Logger.ErrorFormat("CH000:START5"); //Send text message (This is a quote message FROM subscriber TO customer) Logger.ErrorFormat("CH000:START5j-_notificationRepoIsNull{0}, _companyConfigRep{0}", (_notificationRepository== null).ToString(), (_companyConfigRepository== null).ToString()); NotificationAppService notificationService = new NotificationAppService(_notificationRepository, _companyConfigRepository); Logger.ErrorFormat("CH000:START5d"); Logger.ErrorFormat("CH000:START5d-SubscriberID{0}, RequestID{1}", subscriber.Id.ToString(), request.Id.ToString()); Messaging.Dtos.NotificationInput notificationInput = new Dtos.NotificationInput(); Logger.ErrorFormat("CH000:START5e"); notificationInput.CompanyId = input.CompanyId; Logger.ErrorFormat("CH000:START5f"); notificationInput.EmailFrom = emailFrom; Logger.ErrorFormat("CH000:START5g"); notificationInput.EmailSubject = emailSubject; Logger.ErrorFormat("CH000:START5h"); notificationInput.EmailMessage = String.Format("Hello {0}: {1} has submitted a quote. Click here to view the quote.", request.FullName, subscriber.FullName); Logger.ErrorFormat("CH000:START5i"); notificationInput.EmailTo = request.SmsNumber; Logger.ErrorFormat("CH000:START5j"); Logger.ErrorFormat("CH000:START5j-notificationServiceIsNull{0}", (notificationService == null).ToString()); notificationService.SendNotification(notificationInput); Logger.ErrorFormat("CH000:START5k"); Logger.ErrorFormat("CH000:START6"); //Send send email message (This is a email message FROM Subscriber TO customer) //NotificationAppService notificationService = new NotificationAppService(_notificationRepository); notificationService.SendEmailNotification(new Messaging.Dtos.NotificationInput() { CompanyId = input.CompanyId, EmailFrom = emailFrom, EmailSubject = emailSubject, EmailMessage = String.Format("Hello {0}: {1} has submitted a quote. Click here to view the quote.", request.FullName, subscriber.FullName), EmailTo = request.Email }); Logger.ErrorFormat("CH000:START7"); returnResults = new Dtos.GetQuotesResults() { QuoteId = quotesId, ResponseMessage = "Quote successfully sent." }; return returnResults; } catch (System.Exception exc) { Logger.ErrorFormat("CH000:STARTZ{0}EXCSOURCE={1}EXCDATA={2}EXCINNEREXCEPTION{3}", exc.Message, exc.Source, exc.Data, exc.InnerException.Message); returnResults.ResponseMessage = exc.InnerException.Message; return returnResults; } }
public NotificationResults SendEmail(NotificationInput input) { CreditsHero.Messaging.Dtos.NotificationResults results = new CreditsHero.Messaging.Dtos.NotificationResults(); return (CreditsHero.Messaging.Dtos.NotificationResults)_creditsHeroConnect.CallCreditsHeroService<CreditsHero.Messaging.Dtos.NotificationResults>(results, input, "api/services/app/Notification/SendEmailNotification"); }
public async Task<ActionResult> SendAdminEmail() { string role = GetUserRole(); Users.User user = await GetUser(); CreditsHero.Subscribers.Dtos.GetSubscribersInput input = await BuildCreditsHeroSubscriberInput(user); CreditsHero.Messaging.Dtos.NotificationInput inputNotification = new CreditsHero.Messaging.Dtos.NotificationInput() { EmailFrom = input.SubscribersEmail, EmailTo = null, EmailMessage = String.Format("{0}<p/>Company:{1}<br/>SubscriberId:{2}", Request.Form["txtMessage"], input.CompanyId, input.SubscribersId), EmailSubject = String.Format("Notification From {0}", input.SubscribersName), CompanyId = input.CompanyId.Value }; var notificationResults = _memberAppService.SendEmail(inputNotification); rooferlocator.com.Web.Models.ServiceResponse response = new Models.ServiceResponse() { FriendlyMessage = notificationResults.ResponseMessage }; return Redirect((Url.Action("Index", "Home", response))); }
public async Task<ActionResult> Detail() { //Get UserId long userId = long.Parse(Request.Form["Command"].Split('_')[1]); rooferlocator.com.Web.Models.ServiceResponse response = new Models.ServiceResponse(); var user = await _userManager.GetUserByIdAsync(userId); //Determine if we are Deleting, Resetting, or Activating user if (Request.Form["Command"].Contains("ResetPassword")) { #region ResetPassword Command //Generate password reset code for user string resetCode = System.Web.Security.Membership.GeneratePassword(5, 2); //Save user with password reset code user.PasswordResetCode = resetCode; await _userManager.UpdateAsync(user); //Send email to user with password reset code string role = GetUserRole(); CreditsHero.Subscribers.Dtos.GetSubscribersInput input = await BuildCreditsHeroSubscriberInput(user); //NOTE: If EmailTo/EmailFrom is null then email is submitted/replyto to configured admin CreditsHero.Messaging.Dtos.NotificationInput inputNotification = new CreditsHero.Messaging.Dtos.NotificationInput() { EmailFrom = null, EmailTo = user.EmailAddress, EmailMessage = String.Format("<!DOCTYPE html><html lang=en xmlns=http://www.w3.org/1999/xhtml><head><meta charset=utf-8 /><title></title></head><body style='background-color:#3d1617;text-align:center;padding:0px;margin:0px'><div class='col-lg-3 col-md-3 col-sm-3 col-xs-3' style='background:white'></div><div class='col-lg-4 col-md-4 col-sm-4 col-xs-4' style='padding:0px;margin:0px'><div class=row><div class='col-lg-12 col-md-12 col-sm-12 col-xs-12'><img style='width:100%' src=http://www.conciergesworldwide.com/images/imgHeader.jpg /></div></div><div class=row style='padding:10px;height:50px;font-family:Arial;font-size:24pt'><div class='col-lg-12 col-md-12 col-sm-12 col-xs-12' style='border:2px solid white;border-radius:5px'><div class=row style='background-color:gainsboro'><div>Password Reset</div></div><div class='col-lg-12 col-md-12 col-sm-12 col-xs-12' style='padding:10px;color:white'><div style='font-size:16;'>Hello {0}, </p> To reset your password, you will need to enter the following Password Reset Code using the link below. Your password reset code is:<p/><div style='font-size:22;padding:10px;margin:10px;'>{1}</div> <p/></div></div><div class=row style='background-color:gainsboro'><div><a href='{2}{3}'>Click here to reset your password</a></div></div><div class='col-lg-12 col-md-12 col-sm-12 col-xs-12' style='border-top:1px solid gainsboro;padding:10px;color:white'><div></div></div></div></div><div class=row></div></div><div class='col-lg-3 col-md-3 col-sm-3 col-xs-3' style='padding:0px;margin:0px'></div></body></html>" , user.Name , user.PasswordResetCode , System.Web.Configuration.WebConfigurationManager.AppSettings["dashboardHero:DashboardPrefix"] , "/Account/ResetPassword"), EmailSubject = String.Format("Password Reset", input.SubscribersName), CompanyId = input.CompanyId.Value }; var notificationResults = _memberAppService.SendEmail(inputNotification); response = new Models.ServiceResponse() { FriendlyMessage = notificationResults.ResponseMessage }; return Redirect((Url.Action("Index", "Members", response))); #endregion } else if (Request.Form["Command"].Contains("UserDetails")) { #region ShowDetails Command CreditsHero.Subscribers.Dtos.GetSubscribersInput input = await BuildCreditsHeroSubscriberInput(user); //Get Member Info (credits hero) var outputSubscriber = _memberAppService.GetMember(input); //Get Member Info var outputMember = _memberAppService.GetMembers(new Common.Members.Dtos.GetMemberInput() { MemberId = Int32.Parse(user.Id.ToString()) }); //Get Member Subscriptions var outputSubscriptions = _memberAppService.GetMemberSubscriptions(input); rooferlocator.com.Common.Members.Dtos.MemberDto output = outputMember.Members[0]; output.SubscriberSkills = outputSubscriptions; return View("Detail", output); #endregion } else if (Request.Form["Command"].Contains("Activate")) { #region ActivateUser Command user.IsDeleted = false; var results = await _userManager.UpdateAsync(user); if (results.Succeeded) { response = new Models.ServiceResponse() { FriendlyMessage = "Member has been removed." }; } return Redirect((Url.Action("Index", "Members", response))); #endregion } else if (Request.Form["Command"].Contains("Delete")) { #region DeleteUser Command user.IsDeleted = true; var results = await _userManager.UpdateAsync(user); if (results.Succeeded) { response = new Models.ServiceResponse() { FriendlyMessage = "Member has been removed." }; } return Redirect((Url.Action("Index", "Members", response))); #endregion } return View(); }
public object SendEmail(CreditsHero.Messaging.Requests.Dtos.GetInquiryInput inquiryInput, string emailFrom, string emailSubject, string emailTo, string emailBodyOverride) { MemoryStream jsonStream = new MemoryStream(); string jsonData = Newtonsoft.Json.JsonConvert.SerializeObject(inquiryInput); byte[] byteArray = Encoding.UTF8.GetBytes(jsonData); //Send Inquiry Email to Admin var creditsHeroFormat = String.Format("{0}api/services/app/Notification/SendEmailNotification", WebConfigurationManager.AppSettings["creditsHero:WebServiceApiPrefix"]); CreditsHero.Messaging.Dtos.NotificationInput emailInput = new CreditsHero.Messaging.Dtos.NotificationInput(); var timelineUrl = string.Format(creditsHeroFormat); CreditsHero.Messaging.Requests.Dtos.GetInquiryResults inquiryResults; List<KeyValuePair<string, string>> inquiryValues = new List<KeyValuePair<string, string>>(); inquiryValues = inquiryInput.QueryRequest; if(emailBodyOverride == string.Empty) { emailBodyOverride = String.Format("<!DOCTYPE html><html lang=en xmlns='http://www.w3.org/1999/xhtml'><head><meta charset=utf-8 /><title></title><link rel='stylesheet' href='/Content/bootstrap-cosmo.min.css' /></head><body style='background-color:gainsboro;text-align:center;padding:0px;margin:0px'><div class='row' style='padding:0px;margin:0px;'> <div class='col-lg-2 col-md-2 col-sm-2 col-xs-2'></div><div class='col-lg-8 col-md-8 col-sm-8 col-xs-8' style='padding:0px;margin:0px'> <div class='row'> <div class='col-lg-2 col-md-2 col-sm-2 col-xs-2'></div><div class='col-lg-8 col-md-8 col-sm-8 col-xs-8' style='box-shadow: 5px 0px 5px -4px rgba(31,73,125,0.8), -5px 0px 8px -5px rgba(31,73,125,0.8); background-image: -ms-linear-gradient(rgb(25, 68, 125) 20%, rgb(32, 128, 190) 100%);'> <img src='/images/rooferlocatorlogo_70x170.png' /> <div class='row' style='padding:0px;margin:0px;height:50px;font-family:Arial;font-size:24pt'> <div class='col-lg-12 col-md-12 col-sm-12 col-xs-12' style='border:2px solid white;border-radius:5px; background:white;'> <div class='row' style='padding-left:13px;padding-right:13px;border-radius:5px;'> <div class='col-lg-12 col-md-12 col-sm-12 col-xs-12' style='background:#fe7900;'>Inquiry</div></div><div class='row' style='color:black'> <div class='col-lg-12 col-md-12 col-sm-12 col-xs-12' style='font-size:16px;'>Hello Administrator: <br/> An inquiry/search has been submitted at RooferLocator.com.<p/> Following are the details of the inquiry:<p/> <strong>Roof Type = {0}</strong> <br/> <strong>Service Type = {1}</strong> <br/> <strong>Time Of Repair = {2}</strong> <br/> <strong>State = {3}</strong> <br/> <strong>City = {4}</strong></div></div><div class='row' style='padding-left:13px;padding-right:13px;border-radius:5px;'> <div class='col-lg-12 col-md-12 col-sm-12 col-xs-12' style='background:#fe7900;'>Comment</div></div><div class='col-lg-12 col-md-12 col-sm-12 col-xs-12' style='border-top:1px solid gainsboro;padding:10px;color:black'> <div>{1}</div></div></div></div></div><div class='col-lg-2 col-md-2 col-sm-2 col-xs-2'></div></div></div><div class='col-lg-2 col-md-2 col-sm-2 col-xs-2' style='padding:0px;margin:0px'></div></div></body></html>", inquiryValues[0].Value, inquiryValues[1].Value, inquiryValues[2].Value, inquiryValues[3].Value, inquiryValues[4].Value); } emailInput = new CreditsHero.Messaging.Dtos.NotificationInput() { CompanyId = Guid.Parse(System.Web.Configuration.WebConfigurationManager.AppSettings["creditsHero:CompanyId"]), EmailFrom = emailFrom, EmailSubject = String.Format(emailSubject), EmailMessage = emailBodyOverride, EmailTo = emailTo }; jsonData = Newtonsoft.Json.JsonConvert.SerializeObject(emailInput); byteArray = Encoding.UTF8.GetBytes(jsonData); HttpWebRequest creditsHeroRequest = (HttpWebRequest)WebRequest.Create(timelineUrl); creditsHeroRequest.ContentType = "application/json;charset=utf-8"; creditsHeroRequest.ContentLength = byteArray.Length; creditsHeroRequest.Method = "POST"; Stream newStream = creditsHeroRequest.GetRequestStream(); newStream.Write(byteArray, 0, byteArray.Length); newStream.Close(); WebResponse timeLineResponse = creditsHeroRequest.GetResponse(); using (timeLineResponse) { using (var reader = new StreamReader(timeLineResponse.GetResponseStream())) { var results = Newtonsoft.Json.JsonConvert.DeserializeObject<dynamic>(reader.ReadToEnd()); Newtonsoft.Json.Linq.JObject jObject2 = results.result; var itemResult = Newtonsoft.Json.JsonConvert.DeserializeObject<CreditsHero.Messaging.Requests.Dtos.GetInquiryResults>(jObject2.ToString()); inquiryResults = itemResult; return inquiryResults; } } }