public ActionResult Form(Guid registrationId) { if (ControllerContext.HttpContext.Session["authenticated"] != null) { viewModel = new PageModel { Title = "Already registered" }; return(View("AlreadyRegistered", viewModel)); } if (RegistrationRepository.IsRegistered(registrationId)) { viewModel = new PageModel { Title = "Waiting activation" }; return(View("WaitingActivation", viewModel)); } var registerPageViewModel = new RegisterPageModel { Title = "Register", Command = new RegisterCommand { RegistrationId = registrationId } }; viewModel = registerPageViewModel; return(View("RegisterForm", registerPageViewModel)); }
public async Task <CustomReturn <User> > Register(RegisterPageModel register) { var resultConnection = await ValidateConnection(); if (!resultConnection.IsValid) { return(new CustomReturn <User>(resultConnection.Error)); } var jsonObject = JsonConvert.SerializeObject(register); var httpResponse = await HttpClient.PostAsync($"{UrlService}/user/register", new StringContent(jsonObject, Encoding.UTF8, "application/json")); if (httpResponse.IsSuccessStatusCode && httpResponse.StatusCode == HttpStatusCode.OK) { var json = await httpResponse.Content.ReadAsStringAsync(); var result = JsonConvert.DeserializeObject <User>(json); return(new CustomReturn <User>(result)); } var error = await GetError(httpResponse); return(new CustomReturn <User>(error)); }
public ActionResult Register(RegisterPageModel model) { //run server validation var errors = DataAnnotationsValidationRunner.GetErrors(model); if (!EmailValidator.IsValidEmail(model.Email)) { errors.Add(new ErrorInfo("Email", "Invalid email address", model)); } if (model.HumanValue != "12") { errors.Add(new ErrorInfo("HumanValue", "Are you human???", model)); } if (errors.Any()) { return View(model); } var attendee = Map.RegisterToCurrentAttendee(model); CurrentAttendee.Add(attendee); Emailer.SendConfirmationEmail(attendee); return Redirect("~/attendee/list"); }
public ActionResult Register() { // When registration is off //return RedirectToAction("List"); // When registration is on var model = new RegisterPageModel { CurrentAttendeeCount = CurrentAttendee.GetTotalCount() }; return View(model); }
public ActionResult Register() { // When registration is off //return RedirectToAction("List"); // When registration is on var model = new RegisterPageModel { CurrentAttendeeCount = CurrentAttendee.GetTotalCount() }; return(View(model)); }
public ActionResult Register(RegisterPageModel model) { //run server validation var errors = DataAnnotationsValidationRunner.GetErrors(model); if (errors.Any()) return View(model); var attendee = Map.RegisterToCurrentAttendee(model); CurrentAttendee.Add(attendee); return Redirect("~/attendee/list"); }
public async Task <IActionResult> Register(RegisterPageModel registerPageModel) { if (ModelState.IsValid) { var result = await UserPresentationRepository.Register(registerPageModel.userDto, registerPageModel.ShouldBeAdmin); if (result) { return(Redirect("/Login")); } ModelState.AddModelError("", "Error during register"); } return(View(registerPageModel)); }
//think I need a better mapping system :) public static CurrentAttendee RegisterToCurrentAttendee(RegisterPageModel from) { return new CurrentAttendee { FirstName = from.FirstName, LastName = from.LastName, Name = "{0} {1}".FormatWith(from.FirstName, from.LastName), Email = from.Email, City = from.City, Region = from.Region, Organization = from.Organization, Website = from.Website, Comments = from.Comments ?? "" }; }
{ //think I need a better mapping system :) public static CurrentAttendee RegisterToCurrentAttendee(RegisterPageModel from) { return(new CurrentAttendee { FirstName = from.FirstName, LastName = from.LastName, Name = "{0} {1}".FormatWith(from.FirstName, from.LastName), Email = from.Email, City = from.City, Region = from.Region, Organization = from.Organization, Website = from.Website, Comments = from.Comments ?? "" }); }
public ActionResult Register(RegisterPageModel model) { //run server validation var errors = DataAnnotationsValidationRunner.GetErrors(model); if (errors.Any()) { return(View(model)); } var attendee = Map.RegisterToCurrentAttendee(model); CurrentAttendee.Add(attendee); return(Redirect("~/attendee/list")); }
public void RegisterFailed() { // Navigate to test page landingPage.NavigateTo(); landingPage.InitElements(); landingPage.Click_RegisterPopupButton(); var registerPage = new RegisterPageModel(driver); registerPage.NavigateTo(); registerPage.InitElements(); // Do something registerPage.EnterRegisterCredentials("Fname", "", "*****@*****.**", "Password12345"); registerPage.Click_CreateAccountButton(); // Assert something Assert.True(registerPage.AnyRegistrationErrors()); }
public void RegisterSuccessful() { // Navigate to test page landingPage.NavigateTo(); landingPage.InitElements(); landingPage.Click_RegisterPopupButton(); var registerPage = new RegisterPageModel(driver); registerPage.NavigateTo(); registerPage.InitElements(); // Do something registerPage.EnterRegisterCredentials("Fname", "Lname", "*****@*****.**", "Password12345#"); registerPage.Click_CreateAccountButton(); // Assert something Assert.Empty(registerPage.GetValidationErrors()); }
public async Task <CustomReturn <User> > Register(RegisterPageModel register) { if (string.IsNullOrWhiteSpace(register.FirstName)) { throw new Exception("Campo Nome é obrigatório"); } if (string.IsNullOrWhiteSpace(register.LastName)) { throw new Exception("Campo Sobrenome é obrigatório"); } if (string.IsNullOrWhiteSpace(register.Telephone) || string.IsNullOrWhiteSpace(register.Telephone)) { throw new Exception("Informe pelo menos um número de contato"); } if (!PhoneNumberValidatorBehavior.IsValidPhoneNumber(register.Telephone)) { throw new Exception("Campo Telefone é inválido"); } if (!PhoneNumberValidatorBehavior.IsValidPhoneNumber(register.CellPhone)) { throw new Exception("Campo Celular é inválido"); } if (string.IsNullOrWhiteSpace(register.Cpf)) { throw new Exception("Campo CPF é obrigatório"); } if (!CpfValidatorBehavior.IsValidCpf(register.Cpf)) { throw new Exception("Campo CPF é inválido"); } if (string.IsNullOrWhiteSpace(register.Email)) { throw new Exception("Campo Email é obrigatório"); } if (!EmailHelper.IsEmail(register.Email)) { throw new Exception("Email inválido"); } if (string.IsNullOrWhiteSpace(register.Password)) { throw new Exception("Campo Senha é obrigatório"); } if (string.IsNullOrWhiteSpace(register.ConfirmPassword)) { throw new Exception("Campo Confirmação de Senha é obrigatório"); } if (!string.Equals(register.Password, register.ConfirmPassword)) { throw new Exception("A senha e confirmação não confere"); } var userRest = new UserRest(); var userResult = await userRest.Register(register); if (!userResult.IsValid) { return(userResult); } var tokenRest = new TokenRest(); var token = await tokenRest.Login(new LoginPageModel { UserName = userResult.Value.Cpf, Password = register.Password }); var userToken = new UserTokenVm { User = userResult.Value, Token = token }; Login(userToken); return(userResult); }
public IActionResult Register(RegisterPageModel model) { if (ModelState.IsValid) { var customer = _customerService.Post(new Customer { Forename = model.ForeName, Surname = model.SurName, }); if (customer.Type == StoreFront.Model.Enum.Response.DataResponseType.SUCCESS) { var customerID = Int32.Parse(customer.Details); var addressStatus = _invoiceAddressService.Post(new StoreFront.Model.APIModel.Customer.InvoiceAddress { CustomerID = customerID, Address1 = model.Address1, Address2 = model.Address2 ?? "", Address3 = model.Address3 ?? "", Address4 = model.Town, Address5 = "", Postcode = model.Postcode }); var contactStatus = _contactService.Post(new Contact { CustomerID = customerID, Value = model.Email, ContactTypeID = 1 }); var securityStatus = _securityService.Post(new Security { CustomerID = customerID, Username = Encryption.EncryptString(model.Email), Password = Encryption.EncryptString(model.Password) }); var page = (StoreFront.Service.Register.Register)_page; var transferStatus = _transferService.Post(new BasketTransfer { BasketGUID = page.GUID, CustomerID = customerID }); var claims = new List <Claim> { new Claim(ClaimTypes.Name, customerID.ToString()), new Claim(ClaimTypes.Role, "Administrator"), }; var claimsIdentity = new ClaimsIdentity( claims, CookieAuthenticationDefaults.AuthenticationScheme); var authProperties = new AuthenticationProperties { //AllowRefresh = <bool>, // Refreshing the authentication session should be allowed. ExpiresUtc = DateTimeOffset.UtcNow.AddMinutes(10), // The time at which the authentication ticket expires. A // value set here overrides the ExpireTimeSpan option of // CookieAuthenticationOptions set with AddCookie. IsPersistent = true, // Whether the authentication session is persisted across // multiple requests. Required when setting the // ExpireTimeSpan option of CookieAuthenticationOptions // set with AddCookie. Also required when setting // ExpiresUtc. //IssuedUtc = <DateTimeOffset>, // The time at which the authentication ticket was issued. //RedirectUri = <string> // The full path or absolute URI to be used as an http // redirect response value. }; HttpContext.SignInAsync( CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(claimsIdentity), authProperties); return(RedirectToAction("Index", "Delivery")); } } return(View("Index", _page.Load(model))); }
public RegisterPageViewModel(RegisterPageModel currentPage) : base(currentPage) { _currentPage = currentPage; }