public ActionResult PaymentAccept(CheckBoxValue useDiscount, Guid?couponId, CreditCard creditCard, CheckBoxValue authoriseCreditCard) { var coupon = GetCoupon(couponId); var order = PrepareOrder(Pageflow.ContactProductId, coupon, useDiscount != null && useDiscount.IsChecked, creditCard); try { // Validate the coupon first. ValidateCoupon(Pageflow.ContactProductId, couponId, coupon); // Check that the terms have been accepted but process the other fields as well. if (!authoriseCreditCard.IsChecked) { ModelState.AddModelError(new[] { new CreditCardAuthorisationValidationError("authoriseCreditCard") }, new NewOrderErrorHandler()); } // Validate the coupon. if (couponId != null && coupon == null) { ModelState.AddModelError(new[] { new NotFoundValidationError("coupon", couponId) }, new NewOrderErrorHandler()); } // Validate the credit card. creditCard.Validate(); if (authoriseCreditCard.IsChecked && (couponId == null || coupon != null)) { // Create the user if needed. var employer = CurrentEmployer ?? CreateEmployer(); // Purchase the order. _employerOrdersCommand.PurchaseOrder(employer.Id, order, CreatePurchaser(employer), creditCard); // Save the data. Pageflow.UseDiscount = useDiscount != null && useDiscount.IsChecked; Pageflow.CreditCard = creditCard; Pageflow.AuthoriseCreditCard = true; Pageflow.OrderId = order.Id; // Go to the next page. return(Next()); } } catch (UserException ex) { ModelState.AddModelError(ex, new NewOrderErrorHandler()); } // Show the user the errors. return(PaymentView(Pageflow.ContactProductId, order, Pageflow.CouponCode, useDiscount != null && useDiscount.IsChecked, creditCard, authoriseCreditCard != null && authoriseCreditCard.IsChecked)); }
public ActionResult PrepareOrder(Guid[] productIds, CheckBoxValue useDiscount, Guid?couponId, CreditCardType?creditCardType) { var coupon = couponId == null ? null : _couponsQuery.GetCoupon(couponId.Value); var order = GetOrder(productIds, useDiscount, coupon, creditCardType); return(PartialView("OrderDetails", _employerOrdersQuery.GetOrderDetails(_creditsQuery, order, _productsQuery.GetProducts()))); }
public ActionResult Download(Guid id, [Bind(Include = "IncludeChildOrganisations")] CheckBoxValue includeChildOrganisations) { var organisation = _organisationsQuery.GetOrganisation(id); if (organisation == null) { return(NotFound("organisation", "id", id)); } // Get the employers. var employers = GetEmployers(id, includeChildOrganisations); // Login ids. var loginIds = _loginCredentialsQuery.GetLoginIds(from e in employers select e.Id); // Write them out. var fileStream = (from e in employers select new Tuple <IEmployer, string>( e, loginIds.ContainsKey(e.Id) ? loginIds[e.Id] : null)).ToFileStream(); var fileName = FileSystem.GetValidFileName("LinkMeSearchResults.csv"); return(new FileStreamResult(fileStream, MediaType.Csv) { FileDownloadName = fileName }); }
public ActionResult Download(AdministrativeEmployerSearchCriteria criteria, [Bind(Include = "MatchOrganisationNameExactly")] CheckBoxValue matchOrganisationNameExactly, [Bind(Include = "IsEnabled")] CheckBoxValue isEnabled, [Bind(Include = "IsDisabled")] CheckBoxValue isDisabled) { // Search. criteria.IsEnabled = isEnabled.IsChecked; criteria.IsDisabled = isDisabled.IsChecked; criteria.MatchOrganisationNameExactly = matchOrganisationNameExactly.IsChecked; var employers = _executeEmployerSearchCommand.Search(criteria); // Login ids. var loginIds = _loginCredentialsQuery.GetLoginIds(from e in employers select e.Id); // Write them out. var fileStream = (from e in employers select new Tuple <IEmployer, string>( e, loginIds.ContainsKey(e.Id) ? loginIds[e.Id] : null)).ToFileStream(); var fileName = FileSystem.GetValidFileName("LinkMeSearchResults.csv"); return(new FileStreamResult(fileStream, MediaType.Csv) { FileDownloadName = fileName }); }
private static void UpdateReport(ResumeSearchActivityReport report, CheckBoxValue includeDisabledUsers) { if (includeDisabledUsers != null) { report.IncludeDisabledUsers = includeDisabledUsers.IsChecked; } }
public ActionResult Unsubscribe(Login loginModel, [Bind(Include = "RememberMe")] CheckBoxValue rememberMe) { var result = TryLogIn(loginModel, rememberMe, GetReturnUrl, () => new ActivationErrorHandler()); return(result ?? View(new UnsubscribeModel { Login = loginModel ?? new Login() })); }
public ActionResult Verification(Login loginModel, [Bind(Include = "RememberMe")] CheckBoxValue rememberMe) { var result = TryLogIn(loginModel, rememberMe, r => null, () => new ActivationErrorHandler()); return(result ?? View(new ActivationModel { Login = loginModel })); }
private Order GetOrder(IEnumerable <Guid> productIds, CheckBoxValue useDiscount, Coupon coupon, CreditCardType?creditCardType) { creditCardType = creditCardType ?? default(CreditCardType); return((useDiscount == null || !useDiscount.IsChecked) ? _employerOrdersCommand.PrepareOrder(_productsQuery, _creditsQuery, productIds, coupon, null, creditCardType.Value) : _employerOrdersCommand.PrepareOrder(_productsQuery, _creditsQuery, productIds, coupon, new VecciDiscount { Percentage = 0.2m }, creditCardType.Value)); }
public ActionResult ChangePassword(Guid id, MemberLoginModel memberLogin, [Bind(Include = "SendPasswordEmail")] CheckBoxValue sendPasswordEmail) { var member = _membersQuery.GetMember(id); if (member == null) { return(NotFound("member", "id", id)); } var credentials = _loginCredentialsQuery.GetCredentials(member.Id); if (credentials == null) { return(NotFound("member", "id", id)); } try { // Validate. memberLogin.SendPasswordEmail = sendPasswordEmail.IsChecked; memberLogin.Validate(); // Update. credentials.PasswordHash = LoginCredentials.HashToString(memberLogin.Password); credentials.MustChangePassword = true; _loginCredentialsCommand.UpdateCredentials(member.Id, credentials, User.Id().Value); string message; if (memberLogin.SendPasswordEmail) { var reminderEmail = new PasswordReminderEmail(member, credentials.LoginId, memberLogin.Password); _emailsCommand.TrySend(reminderEmail); message = "The password has been reset and an email has been sent."; } else { message = "The password has been reset."; } return(RedirectToRouteWithConfirmation(MembersRoutes.Edit, new { id }, message)); } catch (UserException ex) { ModelState.AddModelError(ex, new StandardErrorHandler()); } memberLogin.LoginId = credentials.LoginId; return(View("Edit", new UserModel <IMember, MemberLoginModel> { User = _membersQuery.GetMember(id), UserLogin = memberLogin })); }
public ActionResult Join(LinkedInJoin joinModel, [Bind(Include = "AcceptTerms")] CheckBoxValue acceptTerms) { var profile = _linkedInQuery.GetProfile(CurrentAnonymousUser.Id); if (profile == null) { return(RedirectToRoute(HomeRoutes.Home)); } try { joinModel = joinModel ?? new LinkedInJoin(); // Process the post to check validations. if (acceptTerms == null || !acceptTerms.IsChecked) { ModelState.AddModelError(new[] { new TermsValidationError("AcceptTerms") }, new StandardErrorHandler()); } // Try to join. if (acceptTerms != null && acceptTerms.IsChecked) { var account = new EmployerAccount { FirstName = joinModel.FirstName, LastName = joinModel.LastName, EmailAddress = joinModel.EmailAddress, PhoneNumber = joinModel.PhoneNumber, OrganisationName = joinModel.OrganisationName, Location = joinModel.Location, SubRole = joinModel.SubRole, IndustryIds = joinModel.IndustryIds }; _accountsManager.Join(HttpContext, account, profile); return(RedirectToReturnUrl()); } // Not accepting terms so cannot proceed but also check whether any other fields fail validation. joinModel.Prepare(); joinModel.Validate(); } catch (UserException ex) { ModelState.AddModelError(ex, new StandardErrorHandler()); } return(View("Account", GetAccountModel(joinModel))); }
protected ActionResult TryJoin(EmployerJoin join, CheckBoxValue acceptTerms, Func <IErrorHandler> createErrorHandler) { try { join = join ?? new EmployerJoin(); // Process the post to check validations. if (acceptTerms == null || !acceptTerms.IsChecked) { ModelState.AddModelError(new[] { new TermsValidationError("AcceptTerms") }, createErrorHandler()); } // Try to join. if (acceptTerms != null && acceptTerms.IsChecked) { var account = new EmployerAccount { FirstName = join.FirstName, LastName = join.LastName, OrganisationName = join.OrganisationName, EmailAddress = join.EmailAddress, PhoneNumber = join.PhoneNumber, SubRole = join.SubRole, Location = join.Location, IndustryIds = join.IndustryIds, }; var credentials = new AccountLoginCredentials { LoginId = join.JoinLoginId, Password = join.JoinPassword, ConfirmPassword = join.JoinConfirmPassword, }; _accountsManager.Join(HttpContext, account, credentials); return(RedirectToReturnUrl()); } // Not accepting terms so cannot proceed but also check whether any other fields fail validation. join.Prepare(); join.Validate(); } catch (UserException ex) { ModelState.AddModelError(ex, createErrorHandler()); } return(null); }
private static void UpdateReport(EmployerReport report, CheckBoxValue includeChildOrganisations, CheckBoxValue includeDisabledUsers, string promoCode, CheckBoxValue sendToAccountManager, CheckBoxValue sendToClient) { if (report is ResumeSearchActivityReport) { UpdateReport((ResumeSearchActivityReport)report, includeDisabledUsers); } if (report is CandidateCareReport) { UpdateReport((CandidateCareReport)report, promoCode); } UpdateReport(report, includeChildOrganisations, sendToAccountManager, sendToClient); }
public ActionResult LogIn(Login loginModel, [Bind(Include = "RememberMe")] CheckBoxValue rememberMe) { var profile = _linkedInQuery.GetProfile(CurrentAnonymousUser.Id); if (profile == null) { return(RedirectToRoute(HomeRoutes.Home)); } try { loginModel = loginModel ?? new Login(); loginModel.RememberMe = rememberMe != null && rememberMe.IsChecked; var result = _accountsManager.LogIn(HttpContext, loginModel); // Go to the next page. switch (result.Status) { case AuthenticationStatus.Disabled: // If they are disabled, simply redirect them. var faq = _faqsQuery.GetFaq(DisableFaqId); return(RedirectToUrl(faq.GenerateUrl(_faqsQuery.GetCategories()))); case AuthenticationStatus.Failed: throw new AuthenticationFailedException(); case AuthenticationStatus.Deactivated: // Activate them. _userAccountsCommand.ActivateUserAccount(result.User, result.User.Id); break; } // The user has been authenticated so associate them with the LinkedIn profile. profile.UserId = result.User.Id; _linkedInCommand.UpdateProfile(profile); return(RedirectToReturnUrl()); } catch (UserException ex) { ModelState.AddModelError(ex, new StandardErrorHandler()); } return(View("Account", GetAccountModel(loginModel, profile))); }
public ActionResult Report(Guid id, string type, [Bind(Include = "IncludeChildOrganisations")] CheckBoxValue includeChildOrganisations, [Bind(Include = "IncludeDisabledUsers")] CheckBoxValue includeDisabledUsers, [Bind(Include = "PromoCode")] string promoCode, [Bind(Include = "SendToAccountManager")] CheckBoxValue sendToAccountManager, [Bind(Include = "SendToClient")] CheckBoxValue sendToClient) { var organisation = _organisationsQuery.GetOrganisation(id); if (organisation == null) { return(NotFound("organisation", "id", id)); } var isNew = false; var report = _employerReportsQuery.GetReport(id, type); if (report == null) { report = _employerReportsCommand.CreateReportTemplate(id, type); isNew = true; } try { // Update thre report based on its type. UpdateReport(report, includeChildOrganisations, includeDisabledUsers, promoCode, sendToAccountManager, sendToClient); if (isNew) { _employerReportsCommand.CreateReport(report); } else { _employerReportsCommand.UpdateReport(report); } return(RedirectToRoute(OrganisationsRoutes.Report, new { id, type })); } catch (UserException ex) { ModelState.AddModelError(ex, new StandardErrorHandler()); } // Show the errors. return(View(new ReportModel { Organisation = organisation, AccountManager = GetAccountManager(organisation), ContactDetails = GetContactDetails(organisation), Report = report, })); }
public ActionResult Account(Login loginModel, [Bind(Include = "RememberMe")] CheckBoxValue rememberMe) { try { // Process the post to check validations etc. loginModel.RememberMe = rememberMe != null && rememberMe.IsChecked; loginModel.Prepare(); loginModel.Validate(); Save(loginModel, new EmployerJoin(), false); // Authenticate. var result = _loginAuthenticationCommand.AuthenticateUser(new LoginCredentials { LoginId = loginModel.LoginId, PasswordHash = LoginCredentials.HashToString(loginModel.Password) }); switch (result.Status) { // Don't stop the user from purchasing if they need to change their password, they can do that next time they log in. case AuthenticationStatus.Authenticated: case AuthenticationStatus.AuthenticatedMustChangePassword: case AuthenticationStatus.AuthenticatedWithOverridePassword: // Log in. _authenticationManager.LogIn(HttpContext, result.User, result.Status); break; default: throw new AuthenticationFailedException(); } // Go to the next page. return(Next()); } catch (UserException ex) { ModelState.AddModelError(ex, new NewOrderErrorHandler()); } // Show the user the errors. var coupon = GetCoupon(Pageflow.CouponId); var order = PrepareOrder(Pageflow.ContactProductId, coupon, Pageflow.UseDiscount, Pageflow.CreditCard); return(AccountView(order, loginModel, null, false)); }
public ActionResult Account(Login loginModel, [Bind(Include = "RememberMe")] CheckBoxValue rememberMe, EmployerJoin join, [Bind(Include = "AcceptTerms")] CheckBoxValue acceptTerms) { try { // Try to process the login first. if (!loginModel.IsEmpty || (rememberMe != null && rememberMe.IsChecked)) { loginModel.RememberMe = rememberMe != null && rememberMe.IsChecked; loginModel.Prepare(); loginModel.Validate(); Save(loginModel, new EmployerJoin(), false); } else if (!join.IsEmpty || acceptTerms.IsChecked) { if (acceptTerms == null || !acceptTerms.IsChecked) { ModelState.AddModelError(new[] { new TermsValidationError("AcceptTerms") }, new NewOrderErrorHandler()); } join.Prepare(); join.Validate(); Save(new Login(), join, acceptTerms != null && acceptTerms.IsChecked); // Check for an existing login. if (_loginCredentialsQuery.DoCredentialsExist(new LoginCredentials { LoginId = join.JoinLoginId })) { throw new DuplicateUserException(); } } // Go to the previous page. return(Previous()); } catch (UserException ex) { ModelState.AddModelError(ex, new NewOrderErrorHandler()); } // Show the user the errors. var coupon = GetCoupon(Pageflow.CouponId); var order = PrepareOrder(Pageflow.ContactProductId, coupon, Pageflow.UseDiscount, Pageflow.CreditCard); return(AccountView(order, loginModel, join, acceptTerms != null && acceptTerms.IsChecked)); }
public ActionResult Search(OrganisationSearchCriteria criteria, [Bind(Include = "VerifiedOrganisations")] CheckBoxValue verifiedOrganisations, [Bind(Include = "UnverifiedOrganisations")] CheckBoxValue unverifiedOrganisations) { var accountManagers = _administratorsQuery.GetAdministrators(); criteria.VerifiedOrganisations = verifiedOrganisations.IsChecked; criteria.UnverifiedOrganisations = unverifiedOrganisations.IsChecked; var organisations = _executeOrganisationSearchCommand.Search(criteria); return(View(new OrganisationSearchModel { Criteria = criteria, AccountManagers = accountManagers, Organisations = organisations, })); }
private static void UpdateReport(EmployerReport report, CheckBoxValue includeChildOrganisations, CheckBoxValue sendToAccountManager, CheckBoxValue sendToClient) { if (includeChildOrganisations != null) { report.IncludeChildOrganisations = includeChildOrganisations.IsChecked; } if (sendToAccountManager != null) { report.SendToAccountManager = sendToAccountManager.IsChecked; } if (sendToClient != null) { report.SendToClient = sendToClient.IsChecked; } }
public ActionResult Payment(CheckBoxValue useDiscount, Guid?couponId, CreditCard creditCard, CheckBoxValue authoriseCreditCard) { var coupon = GetCoupon(couponId); try { if (ShouldProcessPaymentPost(couponId, creditCard, authoriseCreditCard)) { // Validate the coupon first. ValidateCoupon(Pageflow.ContactProductId, couponId, coupon); // Check that the terms have been accepted but process the other fields as well. if (authoriseCreditCard == null || !authoriseCreditCard.IsChecked) { ModelState.AddModelError(new[] { new CreditCardAuthorisationValidationError("authoriseCreditCard") }, new NewOrderErrorHandler()); } // Validate the credit card. creditCard.Validate(); // Save the data. Pageflow.UseDiscount = useDiscount != null && useDiscount.IsChecked; Pageflow.CreditCard = creditCard; Pageflow.AuthoriseCreditCard = authoriseCreditCard != null && authoriseCreditCard.IsChecked; } // Go to the previous page. return(Previous()); } catch (UserException ex) { ModelState.AddModelError(ex, new NewOrderErrorHandler()); } // Show the user the errors. var order = PrepareOrder(Pageflow.ContactProductId, coupon, useDiscount != null && useDiscount.IsChecked, Pageflow.CreditCard); return(PaymentView(Pageflow.ContactProductId, order, Pageflow.CouponCode, useDiscount != null && useDiscount.IsChecked, creditCard, authoriseCreditCard != null && authoriseCreditCard.IsChecked)); }
public ActionResult Employers(Guid id, [Bind(Include = "IncludeChildOrganisations")] CheckBoxValue includeChildOrganisations) { var organisation = _organisationsQuery.GetOrganisation(id); if (organisation == null) { return(NotFound("organisation", "id", id)); } var employers = GetEmployers(id, includeChildOrganisations); return(View(new EmployersModel { Organisation = organisation, IncludeChildOrganisations = includeChildOrganisations != null && includeChildOrganisations.IsChecked, Employers = employers })); }
public ActionResult Account(EmployerJoin joinModel, [Bind(Include = "AcceptTerms")] CheckBoxValue acceptTerms) { try { // Process the post to check validations. if (acceptTerms == null || !acceptTerms.IsChecked) { ModelState.AddModelError(new[] { new TermsValidationError("AcceptTerms") }, new NewOrderErrorHandler()); } joinModel.Prepare(); joinModel.Validate(); Save(new Login(), joinModel, acceptTerms != null && acceptTerms.IsChecked); if (acceptTerms != null && acceptTerms.IsChecked) { // Check for an existing login. if (_loginCredentialsQuery.DoCredentialsExist(new LoginCredentials { LoginId = joinModel.JoinLoginId })) { throw new DuplicateUserException(); } // Go to the next page. return(Next()); } } catch (UserException ex) { ModelState.AddModelError(ex, new NewOrderErrorHandler()); } // Show the user the errors. var coupon = GetCoupon(Pageflow.CouponId); var order = PrepareOrder(Pageflow.ContactProductId, coupon, Pageflow.UseDiscount, Pageflow.CreditCard); return(AccountView(order, null, joinModel, acceptTerms != null && acceptTerms.IsChecked)); }
private IList <Employer> GetEmployers(Guid organisationId, CheckBoxValue includeChildOrganisations) { IList <Employer> employers; if (includeChildOrganisations != null && includeChildOrganisations.IsChecked) { var organisationHierarchy = _organisationsQuery.GetOrganisationHierarchy(organisationId); var organisationsIds = GetOrganisationsIds(organisationId, organisationHierarchy); employers = _employersQuery.GetOrganisationEmployers(organisationsIds); } else { employers = _employersQuery.GetOrganisationEmployers(organisationId); } return((from e in employers orderby e.Organisation.FullName, e.FullName select e).ToList()); }
/// <summary> /// Converts the WinForm control into WiX custom UI control <see cref="T:WixSharp.Control" />. /// </summary> /// <returns> /// Instance of the WixSharp.Control. /// </returns> /// <exception cref="System.ApplicationException">WixCheckBox (' + control.Id + ') must have BoundProperty set to non-empty value.</exception> public virtual Wix.Controls.Control ToWControl() { Wix.Controls.Control control = this.ConvertToWControl(ControlType.CheckBox); //It is tempting to allow WiX compiler report the problem. However WiX is not reliable with the error reporting. //For example it does it for "CheckBox" but not for "Edit" //Note that control.Name is a better identity value than this.Name, which can be empty. if (BoundProperty.IsEmpty()) { throw new ApplicationException("WixCheckBox ('" + control.Id + "') must have BoundProperty set to non-empty value."); } if (!CheckBoxValue.IsEmpty()) { control.AttributesDefinition += ";CheckBoxValue=" + CheckBoxValue; } return(control); }
protected ActionResult TryLogIn(Login login, CheckBoxValue rememberMe, Func <AuthenticationResult, ReadOnlyUrl> getReturnUrl, Func <IErrorHandler> createErrorHandler) { try { login = login ?? new Login(); login.RememberMe = rememberMe != null && rememberMe.IsChecked; var result = _accountsManager.LogIn(HttpContext, login); // Go to the next page. switch (result.Status) { case AuthenticationStatus.AuthenticatedMustChangePassword: return(RedirectToRoute(AccountsRoutes.MustChangePassword, new RouteValueDictionary(new Dictionary <string, object> { { Apps.Asp.Constants.ReturnUrlParameter, getReturnUrl(result) ?? HttpContext.GetReturnUrl() } }))); case AuthenticationStatus.Disabled: var faq = _faqsQuery.GetFaq(DisableFaqId); return(RedirectToUrl(faq.GenerateUrl(_faqsQuery.GetCategories()))); case AuthenticationStatus.Deactivated: return(GetDeactivatedResult(result, getReturnUrl)); case AuthenticationStatus.Failed: throw new AuthenticationFailedException(); default: return(GetAuthenticatedResult(result, getReturnUrl)); } } catch (UserException ex) { ModelState.AddModelError(ex, createErrorHandler()); } return(null); }
public ActionResult Search(AdministrativeEmployerSearchCriteria criteria, [Bind(Include = "MatchOrganisationNameExactly")] CheckBoxValue matchOrganisationNameExactly, [Bind(Include = "IsEnabled")] CheckBoxValue isEnabled, [Bind(Include = "IsDisabled")] CheckBoxValue isDisabled) { // Search. criteria.IsEnabled = isEnabled.IsChecked; criteria.IsDisabled = isDisabled.IsChecked; criteria.MatchOrganisationNameExactly = matchOrganisationNameExactly.IsChecked; var employers = _executeEmployerSearchCommand.Search(criteria); // Get logins. var loginIds = _loginCredentialsQuery.GetLoginIds(from e in employers select e.Id); return(View(new EmployerSearchModel { Criteria = criteria, Employers = (from e in employers select new EmployerModel { Employer = e, LoginId = loginIds.ContainsKey(e.Id) ? loginIds[e.Id] : null }).ToList() })); }
public ActionResult Home(MemberJoin joinModel, [Bind(Include = "AcceptTerms")] CheckBoxValue acceptTerms) { var result = TryJoin(joinModel, acceptTerms, () => new HomeErrorHandler(HttpContext.GetLoginUrl(), Accounts.Routes.AccountsRoutes.NewPassword.GenerateUrl())); return(result ?? View(CreateHomeModel(UserType.Anonymous, null, joinModel, acceptTerms != null && acceptTerms.IsChecked))); }
public ActionResult ChangePassword(Guid id, EmployerLoginModel employerLogin, [Bind(Include = "SendPasswordEmail")] CheckBoxValue sendPasswordEmail) { var employer = _employersQuery.GetEmployer(id); if (employer == null) { return(NotFound("employer", "id", id)); } var credentials = _loginCredentialsQuery.GetCredentials(employer.Id); if (credentials == null) { return(NotFound("employer", "id", id)); } try { // Validate. employerLogin.SendPasswordEmail = sendPasswordEmail.IsChecked; employerLogin.Validate(); // Update. credentials.PasswordHash = LoginCredentials.HashToString(employerLogin.Password); credentials.MustChangePassword = true; _loginCredentialsCommand.UpdateCredentials(employer.Id, credentials, User.Id().Value); string message; if (employerLogin.SendPasswordEmail) { var members = _accountReportsQuery.GetUsers(UserType.Member, DateTime.Now); _emailsCommand.TrySend(new NewEmployerWelcomeEmail(employer, credentials.LoginId, employerLogin.Password, members)); message = "The password has been reset and an email has been sent."; } else { message = "The password has been reset."; } return(RedirectToRouteWithConfirmation(EmployersRoutes.Edit, new { id }, message)); } catch (UserException ex) { ModelState.AddModelError(ex, new StandardErrorHandler()); } employerLogin.LoginId = credentials.LoginId; return(View("Edit", new UserModel <IEmployer, EmployerLoginModel> { User = _employersQuery.GetEmployer(id), UserLogin = employerLogin })); }
public ActionResult PaymentPurchase(Guid jobAdId, JobAdFeaturePack featurePack, Guid?couponId, CreditCard creditCard, CheckBoxValue authoriseCreditCard) { var employer = CurrentEmployer; var jobAd = GetJobAd(employer.Id, jobAdId); if (jobAd == null) { return(NotFound("job ad", "id", jobAdId)); } var product = _employerOrdersQuery.GetJobAdFeaturePackProduct(featurePack); if (product == null) { return(NotFound("feature pack", "featurePack", featurePack)); } var coupon = GetCoupon(couponId); var order = _employerOrdersCommand.PrepareOrder(new[] { product.Id }, coupon, null, GetCreditCardType(creditCard)); try { // Validate the coupon first. ValidateCoupon(product.Id, couponId, coupon); // Check that the terms have been accepted but process the other fields as well. if (!authoriseCreditCard.IsChecked) { ModelState.AddModelError(new[] { new CreditCardAuthorisationValidationError("authoriseCreditCard") }, new NewOrderErrorHandler()); } // Validate the coupon. if (couponId != null && coupon == null) { ModelState.AddModelError(new[] { new NotFoundValidationError("coupon", couponId) }, new NewOrderErrorHandler()); } // Validate the credit card. creditCard.Validate(); if (authoriseCreditCard.IsChecked && (couponId == null || coupon != null)) { // Purchase the order. _employerOrdersCommand.PurchaseOrder(employer.Id, order, CreatePurchaser(employer), creditCard); // Publish the job ad with the appropriate features. jobAd.Features = _employerOrdersQuery.GetJobAdFeatures(featurePack); jobAd.FeatureBoost = _employerOrdersQuery.GetJobAdFeatureBoost(featurePack); _employerJobAdsCommand.UpdateJobAd(employer, jobAd); return(Publish(employer, jobAd, order.Id)); } } catch (UserException ex) { ModelState.AddModelError(ex, new NewOrderErrorHandler()); } // Show the user the errors. return(View(new PaymentJobAdModel { AuthoriseCreditCard = authoriseCreditCard != null && authoriseCreditCard.IsChecked, CouponCode = coupon == null ? null : coupon.Code, CreditCard = creditCard, OrderDetails = _employerOrdersQuery.GetOrderDetails(_creditsQuery, order, _productsQuery.GetProducts()), Product = product, })); }
public ActionResult Account(Guid jobAdId, JobAdFeaturePack?featurePack, Login loginModel, [Bind(Include = "RememberMe")] CheckBoxValue rememberMe) { try { // Get the job ad. var anonymousUser = CurrentAnonymousUser; var jobAd = GetJobAd(anonymousUser.Id, jobAdId); if (jobAd == null) { return(NotFound("job ad", "id", jobAdId)); } // Process the post to check validations etc. loginModel.RememberMe = rememberMe != null && rememberMe.IsChecked; loginModel.Prepare(); loginModel.Validate(); // Authenticate. var result = _loginAuthenticationCommand.AuthenticateUser(new LoginCredentials { LoginId = loginModel.LoginId, PasswordHash = LoginCredentials.HashToString(loginModel.Password) }); switch (result.Status) { // Don't stop the user from purchasing if they need to change their password, they can do that next time they log in. case AuthenticationStatus.Authenticated: case AuthenticationStatus.AuthenticatedMustChangePassword: case AuthenticationStatus.AuthenticatedWithOverridePassword: // Log in. _authenticationManager.LogIn(HttpContext, result.User, result.Status); break; default: throw new AuthenticationFailedException(); } // Now that the user has logged in, transfer the job ad and publish it. var employer = (IEmployer)result.User; _employerJobAdsCommand.TransferJobAd(employer, jobAd); return(CheckPublish(employer, jobAd, featurePack)); } catch (UserException ex) { ModelState.AddModelError(ex, new StandardErrorHandler()); } // Show the user the errors. return(View(new AccountModel { Login = loginModel, Join = new EmployerJoin(), AcceptTerms = false, Industries = _industriesQuery.GetIndustries() })); }
public ActionResult Account(Guid jobAdId, JobAdFeaturePack?featurePack, EmployerJoin joinModel, [Bind(Include = "AcceptTerms")] CheckBoxValue acceptTerms) { try { // Get the job ad. var anonymousUser = CurrentAnonymousUser; var jobAd = GetJobAd(anonymousUser.Id, jobAdId); if (jobAd == null) { return(NotFound("job ad", "id", jobAdId)); } // Process the post to check validations. if (acceptTerms == null || !acceptTerms.IsChecked) { ModelState.AddModelError(new[] { new TermsValidationError("AcceptTerms") }, new StandardErrorHandler()); } joinModel.Prepare(); joinModel.Validate(); if (acceptTerms != null && acceptTerms.IsChecked) { // Check for an existing login. if (_loginCredentialsQuery.DoCredentialsExist(new LoginCredentials { LoginId = joinModel.JoinLoginId })) { throw new DuplicateUserException(); } // Create the account, transfer the job ad and publish it. var employer = CreateEmployer(joinModel); _employerJobAdsCommand.TransferJobAd(employer, jobAd); // If this job ad is still a draft and a feature pack is requested then need to pay. return(CheckPublish(employer, jobAd, featurePack)); } } catch (UserException ex) { ModelState.AddModelError(ex, new StandardErrorHandler()); } // Show the user the errors. return(View(new AccountModel { Login = new Login(), Join = joinModel, AcceptTerms = acceptTerms != null && acceptTerms.IsChecked, Industries = _industriesQuery.GetIndustries() })); }