Example #1
0
        public ActionResult CreateUser(SignUpVm data)
        {
            if (ModelState.IsValid)
            {
                var context     = new AppDbContext();
                var userStore   = new UserStore <AppUser>(context);
                var userManager = new UserManager <AppUser>(userStore);

                if (data.Password == data.ConfirmPassword)
                {
                    userManager.Create(new AppUser
                    {
                        Email       = data.Email,
                        UserName    = data.Email,
                        FirstName   = data.FirstName,
                        LastName    = data.LastName,
                        PhoneNumber = data.PhoneNumber,
                        Title       = data.Title
                    }, data.Password);

                    var user = userManager.FindByName(data.Email);

                    userManager.AddToRole(user.Id, "User");

                    return(RedirectToAction("ListUser", "Admin"));
                }
                else
                {
                    ViewBag.Error = "Şifreler Uyuşmuyor.";
                    return(View());
                }
            }

            return(View());
        }
Example #2
0
        // GET: Admin
        public ActionResult Index()
        {
            using (NewsletterEntities db = new NewsletterEntities())
            {
                // lambda expression to sort out "Unsubscribed" people:
                var signups = db.SignUps.Where(x => x.Removed == null).ToList();

                // Uses SQL like statement from LINQ to sort list to only display active subscribers:
                ///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
                    {
                        Id           = signup.Id,
                        FirstName    = signup.FirstName,
                        LastName     = signup.LastName,
                        EmailAddress = signup.EmailAddress
                    };
                    signupVms.Add(signupVm);
                }

                return(View(signupVms));
            }
        }
Example #3
0
        public ActionResult SignUp(SignUpVm data)
        {
            var mailManager = new MailManager();

            if (ModelState.IsValid)
            {
                var userManager = service.Uow.Users;
                userManager.Create(new AppUser {
                    Email    = data.Email,
                    UserName = data.SignupUsername,
                    EmailVerificationCode = Guid.NewGuid().ToString(),
                    ProfilePicPath        = "/Content/Images/ProfilePics/default-pp.jpg",
                    ProfilePicUploadDate  = DateTime.Now,
                    IsActive = true
                }, data.SignupPassword);

                var user = userManager.FindByName(data.SignupUsername);
                userManager.AddToRole(user.Id, "default_user");

                Uri    uri         = new Uri(Request.Url.ToString());
                string mailSubject = "Restoran İnceleme E-posta Aktivasyonu";
                string mailBody    = "Lütfen bağlantıya tıklayarak üyeliğinizi aktif ediniz: " + uri.GetLeftPart(UriPartial.Authority) + "/account/mailverify?username="******"&confirmationCode=" + user.EmailVerificationCode;
                mailManager.SendMail("*****@*****.**", "xxxxxxxx", data.Email, mailSubject, mailBody);

                return(RedirectToAction("Index", "Home"));
            }
            return(RedirectToAction("Index", "Home"));
        }
Example #4
0
        public async Task SignUp(SignUpVm model)
        {
            var existingUser = await _userRepository.GetUserByEmail(model.Email);

            if (existingUser != null)
            {
                throw new BadRequestException("User with this email is already exists");
            }

            var signUpDto = _mapper.Map <SignUpDto>(model);
            var id        = await _userRepository.SignUp(signUpDto);

            //create user root folder
            await _foldersRepository.CreateFolder(new CreateFolderDto
            {
                Name       = $"User {id}  root folder",
                UserId     = id,
                FolderType = FolderType.Private
            });

            var body = await _razorLightEngine.CompileRenderAsync("UserInvitationTemplate.cshtml", new UserInvitationVm
            {
                ActivationUrl   = $"{_commonSettings.ApplicationUrl}/activate_user",
                ActivationToken = signUpDto.ActivationToken,
                FirstName       = model.FirstName,
                LastName        = model.LastName
            });

            _emailService.SendEmail(signUpDto.Email, $"Welcome to Video", body).Forget();
        }
        public ActionResult Admin()
        {
            string queryString = @"SELECT Id, FirstName, LastName, EmailAddress, SocialSecurityNumber 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));
        }
        // GET: Admin
        public ActionResult Index()
        {
            using (NewsletterEntities1 db = new NewsletterEntities1())
            {
                /////OPTION 1: Using lambda to filter unsubscribes out
                //var signups = db.SignUps.Where(x => x.Removed == null).ToList();

                ///OPTION 2: Using Linq to filter results
                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));
            }
        }
Example #7
0
        public async Task <IActionResult> SignUp([FromBody] SignUpVm signUp)
        {
            var us = await _usersService.isUserNameExcist(signUp.Username);

            if (us)
            {
                return(BadRequest(new JsonResult("نام کاربری تکراری است")));
            }
            var q = await _usersService.AddNewUserAsync(signUp);

            return(await Login(q));
        }
Example #8
0
 // GET: Admin
 public ActionResult Index()
 {
     using (NewsletterEntities db = new NewsletterEntities())
     {
         var             signups   = db.SignUps;
         List <SignUpVm> 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;
         }
         return(View(signupVms));
     }
 }
 // GET: Admin
 public ActionResult Index()
 {
     using (CarInsuranceEntities db = new CarInsuranceEntities())
     {
         var signups   = db.SignUps.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;
             signupVm.Quote        = signup.Quote;
             signupVms.Add(signupVm);
         }
         return(View(signupVms));
     }
 }
 // GET: Admin
 public ActionResult Index()
 {
     //Best practice is to wrap Entity statements in using statements, so they close when done
     using (NewsletterEntities db = new NewsletterEntities())
     {
         //var signups = db.SignUps.Where(x => x.Removed == null).ToList();
         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));
     }
 }
 // GET: Admin
 public ActionResult Index()
 {
     using (NewsLetterEntities db = new NewsLetterEntities())
     {
         //var signups = db.SignUpsses.Where( x=> x.Removed == null).ToList();
         var signups = (from c in db.SignUpsses
                        where c.Removed == null
                        select c).ToList();
         List <SignUpVm> 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));
     }
 }
Example #13
0
        //GET: Admin
        public ActionResult Index()

        {
            using (NEWSLETTERNEWEREntities3 db = new NEWSLETTERNEWEREntities3())
            {
                var signups = (from c in db.SignUps
                               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;
                    signupVm.QuoteAmt     = signup.QuoteAmt;
                    signupVms.Add(signupVm);
                }

                return(View(signupVms));
            }
        }
Example #14
0
        // GET: SignUp
        public IActionResult SignUp()
        {
            var user = new SignUpVm();

            return(View(user));
        }
Example #15
0
        public async Task <IActionResult> SignUp([FromBody] SignUpVm model)
        {
            await _userService.SignUp(model);

            return(this.Ok());
        }
Example #16
0
        // GET: Admin
        public ActionResult Index()
        {
            {//NOTE: BELOW IS THE ADO.NET SYNTAX ORIGINALLY USED ; NOW REPLACED BY ENTITY FRAMEWORK SYNTAX (but left the ADO.NET code for learning purposes):END NOTE
             /*going to use ADO.NET to get all the signups off the database to display for the Admin */
             //string queryString = @"SELECT Id, FirstName, LastName, EmailAddress, SocialSecurityNumber FROM SignUps";
             //List<SignUp> signups = new List<SignUp>();/*creating a List of type SignUp and namining the new list "signups"; each item in the list will be referred to as a "signup"*/

                //using (SqlConnection connection = new SqlConnection(connectionString))/*using the sql connection string to get into the database*/
                //{
                //    SqlCommand command = new SqlCommand(queryString, connection);/*passing the queryString (the instructions for the database request) and the connection string info to get SignUps Table information to display for the Admin off of the database*/

                //    connection.Open();

                //    SqlDataReader reader = command.ExecuteReader();/*read the data in the table*/

                //    while (reader.Read())
                //    {
                //        /*here we mapped the data from the SignUp table in the database to the signups list we are creating*/
                //        var signup = new SignUp();/*make a new object called "signup* of type "SignUp"(this is our model class "SignUp") made up of the information that we are reading from the database*/
                //        signup.Id = Convert.ToInt32(reader["Id"]);/*we have to convert the information gathered off the database to a format that c sharp can understand*/

                //        signup.FirstName = reader["FirstName"].ToString();
                //        signup.LastName = reader["LastName"].ToString();
                //        signup.EmailAddress = reader["EmailAddress"].ToString();
                //        signup.SocialSecurityNumber = reader["SocialSecurityNumber"].ToString();

                //        signups.Add(signup);/*we are adding this new information(signup.FirstName, signup.LastName, etc....) to our new "signups" list*/

                //    }
                //}

                //ENTITY FRAMEWORK SYNTAX STARTS HERE:
                //(Note:Entity Framework serves as a wrapper for condensed ADO.NET code)

                using (NewsletterEntities db = new NewsletterEntities()) //using entity syntax to instanciate the NewsletterEntities object that gives us access to the database through the Entity Framework
                {                                                        //Alternate way to display only the signed up people***the "WHERE" part below is LINQ syntax and we are looking for the signups that the value of removed is null))
                                                                         // var signups = db.SignUps.Where(x => x.Removed == null).ToList();  // created the variable "signups"; which is equal to db.SignUps(which is the DbSet of the SignUps Table in the database;
                                                                         //and therefore, giving us access to all of the records in the database table)
                                                                         //NOTE: See comments in Newsletter.Context.cs for further explaination of DbSet
                    var signups = (from c in db.SignUps
                                   where c.Removed == null
                                   select c).ToList();

                    //NOTE:This part of the code was used in the ADO.NET Syntax (as is), as well as here in the Entity Framework Syntax(from this line all the way down to the return view line of code)
                    //here we are mapping the values from the signup model(signup) to the signup view model(signupVm)

                    var signupVms = new List <SignUpVm>();//create a new list of view models


                    foreach (var signup in signups)//loop through the database info that has been mapped to a model
                    {
                        var signupVm = new SignUpVm();
                        /*here we map our properties from the signups list we created to the signupVm list we created to display to the ViewModel*/
                        /*we are using the ViewModel to display the info to the Admin User so that we can explicitly choose what data to show */
                        /* (for example: if you were needing to protect against exposure of private info (ie. social security numbers, */
                        /*credit card info., birth date, medical diagnosis, account balance, etc.) that maybe contained in the data transferred fromm the database*/
                        signupVm.Id           = signup.Id;
                        signupVm.FirstName    = signup.FirstName;
                        signupVm.LastName     = signup.LastName;
                        signupVm.EmailAddress = signup.EmailAddress;

                        signupVms.Add(signupVm);//then adding the newly mapped values to the view model list
                    }

                    return(View(signupVms));//then passing this all to the View Model View!!!! Ta-Da!!!Thank you...thank you very much!!!! You're too kind...thank you.
                }
            }
        }
Example #17
0
 protected override Task OnInitializedAsync()
 {
     CheckIsDisabledSubmit = true;
     PageObj = new SignUpVm();
     return(base.OnInitializedAsync());
 }