예제 #1
0
        public Status<bool> Register(EmailAccountRegisterModel model)
        {
            //create message
            var message = new MailMessage { Subject = "Welcome to Rentler!" };
            message.To.Add(model.To);

            //create model for it
            ViewData = new System.Web.Mvc.ViewDataDictionary(model);

            //render it
            PopulateBody(message, viewName: "Register");

            //send it
            return this.SendMessage(message);
        }
예제 #2
0
        public Status <bool> Register(EmailAccountRegisterModel model)
        {
            //create message
            var message = new MailMessage {
                Subject = "Welcome to Rentler!"
            };

            message.To.Add(model.To);

            //create model for it
            ViewData = new System.Web.Mvc.ViewDataDictionary(model);

            //render it
            PopulateBody(message, viewName: "Register");

            //send it
            return(this.SendMessage(message));
        }
예제 #3
0
 public Status<bool> Register(EmailAccountRegisterModel model)
 {
     return SendMail(model, "account/register");
 }
예제 #4
0
        public ActionResult Register(EmailAccountRegisterModel model)
        {
            var status = mailer.Register(model);

            return Json(status, JsonRequestBehavior.AllowGet);
        }
예제 #5
0
        /// <summary>
        /// Registers the specified user.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <param name="password">The password.</param>
        /// <returns></returns>
        public Status<User> RegisterUser(User user, string password)
        {
            user.CreateDateUtc = DateTime.UtcNow;
            user.UpdateDateUtc = DateTime.UtcNow;
            user.UpdatedBy = "AccountAdapter";

            // validate the object
            var result = Status.Validatate<User>(user);
            if (result.StatusCode != 200)
                return result;

            if (string.IsNullOrWhiteSpace(password))
                return Status.ValidationError<User>(null, "Password", "The password was not specified");

            using (var context = new RentlerContext())
            {
                try
                {
                    // check for dup email
                    var dupEmail = context.Users.Where(u => !u.IsDeleted && u.Email.ToLower() == user.Email.ToLower()).Count();
                    if (dupEmail > 0)
                    {
                        return Status.ValidationError<User>(null, "Email", "The email is already used");
                    }

                    // check for dup username
                    var dupUser = context.Users.Where(u => !u.IsDeleted && u.Username.ToLower() == user.Username.ToLower()).Count();
                    if (dupUser > 0)
                    {
                        return Status.ValidationError<User>(null, "Username", "The username is already used");
                    }

                    user.PasswordHash = FormsAuthentication.HashPasswordForStoringInConfigFile(password, "SHA1");

                    // create the user
                    context.Users.Add(user);
                    context.SaveChanges();

                    // notify user by email that their password was changed successfully.
                    EmailAccountRegisterModel model = new EmailAccountRegisterModel()
                    {
                        Name = string.Format("{0} {1}", user.FirstName, user.LastName),
                        To = user.Email
                    };
                    mailer.Register(model);

                    return Status<User>.OK(user);
                }
                catch (Exception ex)
                {
                    // TODO: log exception
                    return Status.Error<User>("System was unable to create user", null);
                }
            }
        }
예제 #6
0
 public Status <bool> Register(EmailAccountRegisterModel model)
 {
     return(SendMail(model, "account/register"));
 }