Example #1
0
		public void MailManagerTest_SendContactUsFromLoggedUser()
		{
			var contactUsViewModel = new ContactUsViewModel()
			{
				CompanyName = "Company Name",
				Email = "*****@*****.**",
				Message = "I wrote this message",
				Name = "Name",
				PhoneNumber = "111111111111111111",
				UserDetailsUrl = "user details link"
			};

			var user = new User()
			{
				Email = "*****@*****.**",
				FirstName = "First Name",
				LastName = "Last Name",
				Roles = new List<Role>() { new Role() { DisplayName = "testrole", Id = (int)RoleType.AppraisalCompanyAdmin } },
			};
			var dict = new Dictionary<AppraiserUserStatus, string>();
			dict.Add(AppraiserUserStatus.Active, "testStatus");
			_usersManagement.GetByEmail(Arg.Any<string>()).Returns(user);
			_appraiserManagement.GetByEmail(Arg.Any<string>()).Returns(new AppraiserUser() { Status = AppraiserUserStatus.Active });
			_referenceManagement.GetAppraisalUserStatuses().Returns(dict);

			_target.SendContactUsLoggedUser(contactUsViewModel, user.Email);
		}
Example #2
0
		private string BuildContactMessage(ContactUsViewModel model, bool IsAuthenticated, string userName)
		{
			User currentUser = null;
			AppraiserUser appraiser = null;
			if (User.Identity.IsAuthenticated && ModelState.IsValid)
			{
				currentUser = _userManagement.GetByEmail(User.Identity.Name);
				appraiser = _appraiserManagement.GetByEmail(currentUser.Email);
			}
			var messageBuilder = new StringBuilder();
			messageBuilder.Append("Hello.\r\nThe following user has sent you a message:\r\n");

			AddFieldToMessage(messageBuilder, "Name: ", model.Name);
			AddFieldToMessage(messageBuilder, "Email: ", model.Email);

			if (!string.IsNullOrEmpty(model.PhoneNumber))
			{
				AddFieldToMessage(messageBuilder, "Phone Number: ", model.PhoneNumber);
			}

			if (currentUser != null)
			{
				AddFieldToMessage(messageBuilder, "Security role: ", currentUser.PrimaryRole.DisplayName);
				AddFieldToMessage(messageBuilder, "Status: ", Singletones.ReferenceManager.GetUserStatus()[currentUser.IsActivated]);
			}

			if (appraiser != null)
			{
				if (appraiser.Company != null)
					AddFieldToMessage(messageBuilder, "Company Id: ", appraiser.Company.CompanyId);
			}

			if (!string.IsNullOrEmpty(model.CompanyName))
			{
				AddFieldToMessage(messageBuilder, "Company name: ", model.CompanyName);
			}

			if (appraiser != null)
			{
				var companyStatuses = Singletones.ReferenceManager.GetAppraisalCompanyStatuses();
				if (appraiser.Company != null)
					AddFieldToMessage(messageBuilder, "Company status: ", companyStatuses[appraiser.Company.Status]);
				if (appraiser.Branch != null)
				{
					AddFieldToMessage(messageBuilder, "Branch name: ", appraiser.Branch.Name);
					AddFieldToMessage(messageBuilder, "Branch status: ", companyStatuses[appraiser.Branch.Status]);
				}
			}

			AddFieldToMessage(messageBuilder, "Message text: ", model.Message);

			return messageBuilder.ToString();
		}
Example #3
0
		public void MailManagerTest_SendContactUsFromAnonym()
		{
			var contactUsViewModel = new ContactUsViewModel()
			{
				CompanyName = "Company Name",
				Email = "*****@*****.**",
				Message = "I wrote this message",
				Name = "Name",
				PhoneNumber = "111111111111111111",
			};

			_target.SendContactUsFromAnonym(contactUsViewModel);
		}
Example #4
0
		public void SendContactUsFromAnonym(ContactUsViewModel model)
		{
			string phoneSection = GetPhoneSection(model.PhoneNumber);
			string companySection = string.IsNullOrWhiteSpace(model.CompanyName) ?
												string.Empty :
												string.Format("Company: {0}", model.CompanyName);

			Dictionary<string, string> replaceDictionary = new Dictionary<string, string>();
			replaceDictionary.Add(Constants.EmailTemplateKeyWords.UserName, model.Name);
			replaceDictionary.Add(Constants.EmailTemplateKeyWords.MessageText, model.Message);
			replaceDictionary.Add(Constants.EmailTemplateKeyWords.UserEmail, model.Email);
			replaceDictionary.Add(Constants.EmailTemplateKeyWords.PhoneSection, phoneSection);
			replaceDictionary.Add(Constants.EmailTemplateKeyWords.CompanyInfoSection, companySection);

			SendMailInternal(EmailTemplateType.ContactUsAnonymUser, _configManager.SupportEmail, replaceDictionary);
		}
Example #5
0
		private void FillContuctUsModel(ContactUsViewModel model, User user)
		{
			model.Name = user.FullName;
			model.Email = user.Email;

			Phone userPhone = null;
			var appraiser = _appraiserManagement.GetByEmail(user.Email);

			if (appraiser == null)
			{
				userPhone = GetUserPhone(user.Phones);
			}
			else
			{
				if (appraiser.ContactInfo != null)
				{
					userPhone = GetUserPhone(appraiser.ContactInfo.Phones);
				}
				if (appraiser.Company != null)
				{
					model.CompanyName = appraiser.Company.CompanyName;
					model.HasCompany = true;
				}
			}
			model.PhoneNumber = userPhone != null ? userPhone.Number : string.Empty;
		}
Example #6
0
		public ActionResult ContactUs(ContactUsViewModel model)
		{
			if (User.Identity.IsAuthenticated)
				ModelState.Remove("CaptchaAnswer");
			if (!ModelState.IsValid)
			{
				return View(model);
			}
			var urlHelper = new UrlHelper(this.Request.RequestContext);

			if (User.Identity.IsAuthenticated)
			{
				if (SecurityContext.CurrentUser.HasUserAnyRoles(RoleType.DvsAdmin, RoleType.DvsSuperAdmin))
				{
					model.UserDetailsUrl = urlHelper.AbsoluteAction("UserDetails", "DVSViewEdit", new { area = "UserManagement", Id = SecurityContext.CurrentUser.Id });
				}
				else if (SecurityContext.CurrentUser.HasUserAnyRoles(RoleType.Appraiser, RoleType.AppraisalCompanyAdmin, RoleType.CompanyAdminAndAppraiser))
				{
					model.UserDetailsUrl = urlHelper.AbsoluteAction("Index", "AppraiserProfile", new { area = "Appraiser", userId = SecurityContext.CurrentUser.Id });
				}
				_taskManager.ScheduleContactUsFromLoggedUserNotification(
					SecurityContext.CurrentUser.Email,
					model.Email,
					model.Message,
					model.PhoneNumber,
					model.Name,
					model.UserDetailsUrl
					);
			}
			else
			{
				_taskManager.ScheduleContactUsFromAnonymNotification(
					model.Email,
					model.Message,
					model.PhoneNumber,
					model.Name,
					model.CompanyName);
			}
			ViewBag.ConfirmMessage = string.Format(Constants.ConfirmMessages.ContactUsSuccessMessage, model.Name);

			return View(model);
		}
Example #7
0
		public ActionResult ContactUs()
		{
			var model = new ContactUsViewModel();
			if (Request.UrlReferrer != null && !Request.UrlReferrer.ToString().Contains("/Home/Login"))
			{
				model.Referrer = Request.UrlReferrer.ToString();
			}
			else
			{
				model.Referrer = Url.Action(NameHelper.Home.Index);
			}
			if (User.Identity.IsAuthenticated)
			{
				FillContuctUsModel(model, SecurityContext.CurrentUser);
			}
			else
			{
				model.Referrer = Url.Content("~/");
			}
			return View(model);
		}
Example #8
0
		public void SendContactUsLoggedUser(ContactUsViewModel model, string userEmail)
		{
			var contactUser = _userManagement.GetByEmail(userEmail);
			string phoneSection = GetPhoneSection(model.PhoneNumber);
			var appraiser = _appraiserManagement.GetByEmail(contactUser.Email);
			string companyInfoSection = string.Empty;
			if (appraiser != null && appraiser.Company != null)
			{
				companyInfoSection = string.Format(" of '{0}' company (id: {1})", appraiser.Company.CompanyName, appraiser.Company.CompanyId);
			}
			string userStatus = GetUserStatusByRole(contactUser);

			Dictionary<string, string> replaceDictionary = new Dictionary<string, string>();

			replaceDictionary.Add(Constants.EmailTemplateKeyWords.UserName, model.Name);
			replaceDictionary.Add(Constants.EmailTemplateKeyWords.SecurityRole, contactUser.PrimaryRole.DisplayName);
			replaceDictionary.Add(Constants.EmailTemplateKeyWords.MessageText, model.Message);
			replaceDictionary.Add(Constants.EmailTemplateKeyWords.UserEmail, model.Email);
			replaceDictionary.Add(Constants.EmailTemplateKeyWords.PhoneSection, phoneSection);
			replaceDictionary.Add(Constants.EmailTemplateKeyWords.CompanyInfoSection, companyInfoSection);
			replaceDictionary.Add(Constants.EmailTemplateKeyWords.UserDetailsPage, model.UserDetailsUrl);
			replaceDictionary.Add(Constants.EmailTemplateKeyWords.UserStatus, userStatus);

			SendMailInternal(EmailTemplateType.ContactUsLoggedUser, _configManager.SupportEmail, replaceDictionary);
		}
Example #9
0
		private void SendContactUsFromAnonymEmail()
		{
			var model = new ContactUsViewModel()
			{
				Email = GetParamValue(TaskParamsKey.UserContactEmail),
				Message = GetParamValue(TaskParamsKey.Message),
				Name = GetParamValue(TaskParamsKey.UserName),
				PhoneNumber = GetParamValue(TaskParamsKey.Phone, false),
				CompanyName = GetParamValue(TaskParamsKey.CompanyName, false)
			};
			_mailManager.SendContactUsFromAnonym(model);
		}
Example #10
0
		private void SendContactUsFromLoggedUserEmail()
		{
			var model = new ContactUsViewModel()
			{
				Email = GetParamValue(TaskParamsKey.UserContactEmail),
				Message = GetParamValue(TaskParamsKey.Message),
				Name = GetParamValue(TaskParamsKey.UserName),
				PhoneNumber = GetParamValue(TaskParamsKey.Phone, false),
				UserDetailsUrl = GetParamValue(TaskParamsKey.UserDetailsUrl)
			};
			_mailManager.SendContactUsLoggedUser(model, GetEmailByUserId());
		}