public ActionResult Admin()
        {
            string queryString = @"SELECT * FROM SignUps";
            List <NewsLetterSignUp> signups = new List <NewsLetterSignUp>();

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlCommand command = new SqlCommand(queryString, connection);
                connection.Open();
                SqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    var signup = new NewsLetterSignUp();
                    signup.id                   = Convert.ToInt32(reader["Id"]);
                    signup.FirstName            = reader["FirstName"].ToString();
                    signup.LastName             = reader["LastName"].ToString();
                    signup.EmailAddress         = reader["EmailAddress"].ToString();
                    signup.SocialSecurityNumber = reader["SocialSecurityNumber"].ToString();
                    signups.Add(signup);
                }
            }
            var signUpVMs = new List <SignUpVM>();

            foreach (var signup in signups)
            {
                var signUpVM = new SignUpVM();
                signUpVM.FirstName    = signup.FirstName;
                signUpVM.LastName     = signup.LastName;
                signUpVM.EmailAddress = signup.EmailAddress;
                signUpVMs.Add(signUpVM);
            }
            return(View(signUpVMs));
        }
Exemple #2
0
        // GET: Admin
        public ActionResult Index()
        {
            using (NewsletterEntities db = new NewsletterEntities())
            {
                // Lambda way
                //var signups = db.SignUps.Where(x => x.Removed == null).ToList();

                // Linq way
                var signups = (from c in db.SignUps
                               where c.Removed == null
                               select c).ToList();

                var signupVms = new List <SignUpVM>();
                foreach (var signup in signups)
                {
                    var signupVm = new SignUpVM();
                    signupVm.Id           = signup.Id;
                    signupVm.firstName    = signup.FirstName;
                    signupVm.lastName     = signup.LastName;
                    signupVm.emailAddress = signup.EmailAddress;
                    signupVms.Add(signupVm);
                }

                return(View(signupVms));
            }
        }
Exemple #3
0
        public async Task <ActionResult> SignUp(SignUpVM vm)
        {
            if (ModelState.IsValid)
            {
                ServiceResult result = await signupService.ExecuteSignup(mapper.Map <SignUpSM>(vm));

                if (result.Valid)
                {
                    return(new JsonResult("Success")
                    {
                        StatusCode = 200
                    });
                }

                return(new JsonResult(
                           new
                {
                    result.Errors
                })
                {
                    StatusCode = 400
                });
            }

            return(new StatusCodeResult(400));
        }
        public ActionResult SignUp()
        {
            SignUpVM model = new SignUpVM();

            model.DropDownList = GetPlans;
            return(View(model));
        }
Exemple #5
0
 public SignUpPage()
 {
     InitializeComponent();
     NavigationPage.SetHasNavigationBar(this, false);
     signUpVM       = new SignUpVM();
     BindingContext = signUpVM;
 }
Exemple #6
0
 public User(SignUpVM user)
 {
     this.userId            = user.userId;
     this.username          = user.username;
     this.password          = user.password;
     this.confirmedpassword = user.confirmedpassword;
 }
Exemple #7
0
        public async Task <IActionResult> SignUp([FromBody] SignUpVM model)
        {
            var user = new ApplicationUser()
            {
                UserName = model.Email, Email = model.Email
            };

            try
            {
                var result = await userManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    await signInManager.SignInAsync(user, isPersistent : false);

                    TokenVM vm = new TokenVM()
                    {
                        ExpiresAt = ExpiresAt, BearerToken = CreateToken(model.Email, model.Email), TokenType = JwtBearerDefaults.AuthenticationScheme, Email = model.Email
                    };
                    return(Ok(vm));
                }
                return(BadRequest());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        // GET: Admin
        public ActionResult Index()
        {
            var signupVMs = new List <SignUpVM>();

            // Generate a list of all signups
            using (var db = new NewsletterDBEntities()) {
                // Alt filter method (using "Link"(?)):
                //var signups = (from s in db.SignUps
                //               where s.Removed == null
                //               select s).ToList();

                foreach (var signup in db.SignUps.Where(x => x.Removed == null).ToList())
                {
                    var signupVM = new SignUpVM();
                    signupVM.Id           = signup.Id;
                    signupVM.FirstName    = signup.FirstName;
                    signupVM.LastName     = signup.LastName;
                    signupVM.EmailAddress = signup.EmailAddress;
                    signupVMs.Add(signupVM);
                }
            }

            // Submit them with the view
            return(View(signupVMs));
        }
        public SignUpPage()
        {
            BindingContext = new SignUpVM();

            ((SignUpVM)BindingContext).NavigateToPageEvent += NavigateToPageAsync;
            InitializeComponent();
        }
Exemple #10
0
        public ActionResult SignUp(SignUpVM singUpVm)
        {
            int result = 0;

            if (ModelState.IsValid)
            {
                var isExist = DataService.Service.WebUserService.GetAll().Any(x => x.Email == singUpVm.Email);

                if (!isExist)
                {
                    WebUser newUser = new WebUser()
                    {
                        Email    = singUpVm.Email,
                        Password = singUpVm.Password,
                        Name     = singUpVm.FirstName,
                        LastName = singUpVm.LastName,
                        Role     = "user",
                    };
                    result = DataService.Service.WebUserService.Insert(newUser);
                }
            }
            if (result != 0)
            {
                return(Redirect("/Account/Login"));
            }
            else
            {
                return(Redirect("/admin/Account/SingUp"));
            }
        }
Exemple #11
0
        public async Task <IActionResult> SignUp(SignUpVM user)
        {
            if (!ModelState.IsValid)
            {
                return(View(user));
            }

            AppUser appUser = new AppUser
            {
                Name     = user.Name,
                Surname  = user.Surname,
                UserName = user.Username,
                Email    = user.Email,
                Birthday = user.Birthday
            };

            IdentityResult result = await _userManager.CreateAsync(appUser, user.Password);

            if (!result.Succeeded)
            {
                foreach (var error in result.Errors)
                {
                    ModelState.AddModelError("", error.Description);
                }
                return(View(user));
            }

            await _userManager.AddToRoleAsync(appUser, UserRoles.MemberRole);

            await _signInManager.SignInAsync(appUser, true);

            return(RedirectToAction("Newsfeed", "Account"));
        }
 public XF_SignUpPage()
 {
     InitializeComponent();
     signUpVM = new SignUpVM();
     //set binding
     BindingContext = signUpVM;
 }
Exemple #13
0
 public SignUpPage()
 {
     //This is for Testing its not needed
     InitializeComponent();
     signUpVM = new SignUpVM();
     //set binding
     BindingContext = signUpVM;
 }
Exemple #14
0
        public IActionResult SignUp(string returnUrl = null)
        {
            returnUrl ??= Url.Content("~/");

            var model = new SignUpVM();

            model.ReturnUrl = returnUrl;

            return(View(model));
        }
Exemple #15
0
        public async Task <JsonResult> SignUp(SignUpVM model, string back)
        {
            var result = await _repository.SignupUser(model, RoleName.User);

            if (result == SignInStatus.Success)
            {
                var url = BuildUrl(back);
                return(JsonNet(Message.Ok.ToRedirectResponse(url)));
            }
            return(JsonNet(result));
        }
Exemple #16
0
 public User BuildUser(SignUpVM vm, string id, string username)
 {
     return(new User()
     {
         Email = vm.Email,
         UserName = username,
         Id = id,
         PasswordHash = BuildHashedPassword(vm.Password),
         SecurityStamp = Guid.NewGuid().ToString("D")
     });
 }
Exemple #17
0
        public async Task <IdentityResult> CreateUserAsync(SignUpVM userModel)
        {
            var user = new ApplicationUser()
            {
                FirstName = userModel.FirstName,
                LastName  = userModel.LastName,
                Email     = userModel.Email,
                UserName  = userModel.Email
            };
            var result = await _userManager.CreateAsync(user, userModel.Password);

            return(result);
        }
Exemple #18
0
        public ActionResult SignUp()
        {
            SignUpVM user = new SignUpVM();

            if (Session["username"] != null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                return(View(user));
            }
        }
Exemple #19
0
        public ActionResult SignUp(int id = 0)
        {
            var exchange = DAL.Context.Exchanges.Where(x => x.Id == id)
                           .Select(x => new { Exchange = x, SignUpDate = (DateTime?)x.SignUps.FirstOrDefault(s => s.UserId == BifSessionData.Id).SignUpDate }).FirstOrDefault();

            if (BifSessionData.UserStatus <= 0 || !BifSessionData.HasProfile)
            {
                ViewBag.Message = "Your user profile is still pending.  An administrator will review and approve your profile before you can participate in the exchanges. Please check back soon.";
                return(View("Message"));
            }

            if (exchange?.Exchange == null || DateTime.Now < exchange.Exchange.OpenDate)
            {
                ViewBag.Message = "This exchange is not yet open";
                return(View("Message"));
            }

            if (DateTime.Now >= exchange.Exchange.MatchDate)
            {
                ViewBag.Message = $"The {exchange.Exchange.Name} exchange is closed to new Sign Ups";
                return(View("Message"));
            }

            if (DateTime.Now > exchange.Exchange.CloseDate.AddDays(1))
            {
                ViewBag.Message = $"The {exchange.Exchange.Name} exchange is now closed";
                return(View("Message"));
            }

            SignUpVM vm = new SignUpVM {
                ExchangeId     = id,
                Name           = exchange.Exchange.Name,
                Description    = exchange.Exchange.Description,
                MinCost        = exchange.Exchange.MinCost,
                MinOunces      = exchange.Exchange.MinOunces,
                MinRating      = exchange.Exchange.MinRating,
                MinBoxRating   = exchange.Exchange.MinBoxRating,
                MinUnique      = exchange.Exchange.MinUnique,
                OpenDate       = exchange.Exchange.OpenDate,
                ShipDate       = exchange.Exchange.ShipDate,
                MatchDate      = exchange.Exchange.MatchDate,
                CloseDate      = exchange.Exchange.CloseDate,
                SignUpDate     = exchange.SignUpDate,
                IsAcknowledged = exchange.SignUpDate != null
            };

            return(View("SignUp", vm));
        }
Exemple #20
0
        public async Task <IActionResult> SignUp(SignUpVM model)
        {
            if (ModelState.IsValid)
            {
                var user = new User {
                    UserName = model.Email, Email = model.Email, EmailConfirmed = true
                };
                var result = await _userManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    //_logger.LogInformation("User created a new account with password.");

                    //var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);
                    //code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code));
                    //var callbackUrl = Url.Page(
                    //    "/Account/ConfirmEmail",
                    //    pageHandler: null,
                    //    values: new { area = "Identity", userId = user.Id, code = code },
                    //    protocol: Request.Scheme);

                    _emailSender.SendEmail(new Message(
                                               new string[] { model.Email }, "Założono konto",
                                               $"Twoje konto zostało założone o nazwie <strong>{model.Email}</strong>, przejdź do logowania: <a href='{Url.Action("/Index")}'>logowanie</a>."
                                               ));

                    //if (_userManager.Options.SignIn.RequireConfirmedAccount)
                    //{
                    //    return RedirectToPage("RegisterConfirmation", new { email = model.Email });
                    //}
                    //else
                    //{
                    await _signInManager.SignInAsync(user, isPersistent : false);

                    return(Redirect("/Account/Dashboard"));
                    //}
                }
                foreach (var error in result.Errors)
                {
                    ModelState.AddModelError(string.Empty, error.Description);
                }
            }

            return(View(model));
        }
Exemple #21
0
        public async Task <IActionResult> SignUp(SignUpVM userModel)
        {
            if (ModelState.IsValid)
            {
                var result = await _accountRepository.CreateUserAsync(userModel);

                if (!result.Succeeded)
                {
                    foreach (var errorMessage in result.Errors)
                    {
                        ModelState.AddModelError("", errorMessage.Description);
                    }
                    return(View(userModel));
                }
                return(RedirectToAction("SignIn", "Account"));
            }
            return(View(userModel));
        }
Exemple #22
0
        public ActionResult SignUp(SignUpVM vm)
        {
            if (!vm.IsAcknowledged)
            {
                ModelState.AddModelError("IsAcknowledged", "Please acknowledge the \"Totally Binding Commitment\".");
                return(SignUp(vm.ExchangeId));
            }

            var exchange = DAL.Context.Exchanges.Where(x => x.Id == vm.ExchangeId)
                           .Select(x => new { Exchange = x, IsSignedUp = x.SignUps.Any(s => s.ExchangeId == vm.ExchangeId && s.UserId == BifSessionData.Id) }).FirstOrDefault();

            ViewBag.MessageTitle = "Sign Up";
            if (exchange?.Exchange == null || DateTime.Now < exchange.Exchange.OpenDate)
            {
                ViewBag.Message = "This exchange is not yet open";
                return(View("Message"));
            }

            if (DateTime.Now >= exchange.Exchange.MatchDate)
            {
                ViewBag.Message = "This exchange is closed to new Sign Ups";
                return(View("Message"));
            }

            if (DateTime.Now > exchange.Exchange.CloseDate.AddDays(1))
            {
                ViewBag.Message = "This exchange is now closed";
                return(View("Message"));
            }

            bool success = doSignUp(exchange.Exchange, BifSessionData.Id, vm.Comment?.Trim(), out string message);

            if (!success)
            {
                ViewBag.Message = message;
                return(View("Message"));
            }

            CookieManager.SetCookie(new HttpCookie("exchangeId", exchange.Exchange.Id.ToString()));

            return(RedirectToAction("", ""));
        }
Exemple #23
0
        public IActionResult SignUp(SignUpVM vm)
        {
            if (ModelState.IsValid)
            {
                if (vm.Password != vm.PasswordConfirm)
                {
                    ModelState.AddModelError("PasswordConfirm", "As senhas informadas não são iguais");
                    return(View(vm));
                }


                Usuario usuario = new Usuario();
                usuario.Nome     = vm.Nome;
                usuario.Email    = vm.Email;
                usuario.Password = Usuario.GenerateHash(vm.Password);
                db.Usuarios.Add(usuario);
                db.SaveChanges();
                return(RedirectToAction("Login"));
            }
            return(View(vm));
        }
        public async Task <IActionResult> ExternalLogin([FromBody] SignUpVM externelUser)
        {
            if (ModelState.IsValid)
            {
                ApplicationUser user = await _userManager.FindByNameAsync(externelUser.Username);

                if (user != null)
                {
                    return(await Login(new SignInVM { Username = externelUser.Username, Password = externelUser.Password }));
                }
                //  IActionResult result = await SignUpVM(externelUser);
                ApplicationUser newUser = await _userManager.FindByNameAsync(externelUser.Username);

                string code = await _userManager.GenerateEmailConfirmationTokenAsync(newUser);

                await _userManager.ConfirmEmailAsync(newUser, code);

                return(await Login(new SignInVM { Username = externelUser.Username, Password = externelUser.Password }));
            }
            return(BadRequest(ModelState));
        }
        public async Task <IActionResult> Signup(SignUpVM newUser)
        {
            if (ModelState.IsValid)
            {
                User user = new User
                {
                    UserName     = newUser.UserName,
                    Email        = newUser.Email,
                    PasswordHash = newUser.Password
                };


                var result = await _userManager.CreateAsync(user, user.PasswordHash);

                if (result.Succeeded)
                {
                    Person person = new Person
                    {
                        UserKey     = user.Id,
                        FullName    = "John Doe",
                        PhoneNumber = "123456789",
                        Age         = 0,
                        GenderKey   = 1,
                        CountryKey  = 1,
                        Address     = "Unknown",
                        BirthDate   = new DateTime(1753, 1, 1),
                        Proffesion  = "Unknown",
                        Education   = "Unknown",
                        AboutMe     = "I am ..."
                    };

                    operation.createPerson(person);

                    return(RedirectToAction("Login"));
                }
            }

            return(View(newUser));
        }
Exemple #26
0
        public ActionResult Admin()
        {
            string querystring = @"SELECT Id, FirstName, LastName, EmailAddress, SocialSecurityNumber from SignUps"; //select porperties from the signup tables.
            List <NewsletterSignUp> signups = new List <NewsletterSignUp>();                                         //iniitalize as an empty list

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlCommand command = new SqlCommand(querystring, connection);

                connection.Open();

                SqlDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    var signup = new NewsletterSignUp();
                    signup.Id                   = Convert.ToInt32(reader["id"]);  // assigning the properties/ values coming from the database.
                    signup.FirstName            = reader["FirstName"].ToString(); //objects coming from the database are a different datatype and need to be defined
                    signup.LastName             = reader["LastName"].ToString();
                    signup.EmailAddress         = reader["EmailAddress"].ToString();
                    signup.SocialSecurityNumber = reader["SocialSecurityNumber"].ToString();

                    signups.Add(signup); // add this newsletter signup list
                }
            }
            var signupVMs = new List <SignUpVM>();

            foreach (var signup in signups)
            {
                var signupVM = new SignUpVM();
                signupVM.FirstName    = signup.FirstName;
                signupVM.LastName     = signup.LastName;
                signupVM.EmailAddress = signup.EmailAddress;

                signupVMs.Add(signupVM);
            }

            return(View(signupVMs)); //passes this list to the view
        }
        public ActionResult SignUp(SignUpVM user)
        {
            try
            {
                UserData userData = new UserData();
                userData.name           = user.name;
                userData.last_name      = user.last_name;
                userData.email          = user.email;
                userData.password       = user.password;
                userData.phone          = user.phone;
                userData.dob            = user.dob;
                userData.payment_method = user.payment_method;

                db.UserDatas.Add(userData);
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                ViewBag.error = ex.Message;
                return(View("Error"));
            }
            return(RedirectToAction("Index"));
        }
        // GET: Admin
        public ActionResult Index()
        {
            using (NewsletterModelEntities db = new NewsletterModelEntities())
            {
                var signUps   = db.SignUps;            //this is info from the Context.cs file in the Entity Model Section(represents all the records in the database from the SignUps Table)
                var signUpVMs = new List <SignUpVM>(); // made list called signUpVMs that is made up of items that are the type of  SignUpVM

                foreach (var signUp in signUps)
                {
                    var signUpVM = new SignUpVM();

                    signUpVM.FirstName    = signUp.FirstName; //this way you don't need (signUpVM.FirstName = signup.FirstName)
                    signUpVM.LastName     = signUp.LastName;  //you can shorten it to (FirstName = signup.FirstName), etc...
                    signUpVM.EmailAddress = signUp.EmailAddress;

                    signUpVMs.Add(signUpVM);
                }

                return(View(signUpVMs));
            }

            return(View());
        }
Exemple #29
0
        public ActionResult SignUp(SignUpVM user)
        {
            DAL_Library dal_Library = new DAL_Library();
            User        normUser    = new User(user);

            List <User> users = dal_Library.GetUserList();

            if (user.username == null || user.password == null || user.confirmedpassword == null)
            {
                return(View("SignUp", user));
            }
            else if (users.Any(u => u.username == user.username))
            {
                ViewBag.TheSame = "This username is already taken.";
                return(View("SignUp", user));
            }
            else if (user.password != user.confirmedpassword)
            {
                ViewBag.Password = "******";
                return(View("SignUp", user));
            }
            dal_Library.CreateUser(normUser);
            return(RedirectToAction("Index", "Home"));
        }
Exemple #30
0
        public async Task <Microsoft.AspNet.Identity.Owin.SignInStatus> SignupUser(SignUpVM vm, params RoleName[] roles)
        {
            var id   = GenerateId();
            var user = Builder.BuildUser(vm, id, GenerateUsername());

            await AddAsync(user);

            var link = Links.Get(vm.ReferralCode);

            if (link.IsLeftLink)
            {
                await AssignToLeft(link.CreatorId, user.Id);
            }
            else
            {
                await AssignToRight(link.CreatorId, user.Id);
            }

            await Auth.AddToRoleAsync(id, roles);

            await _notify.AddAsync(id, Message.Welcome);

            return(await Auth.Login(user.UserName, vm.Password));
        }