Esempio n. 1
0
        public ActionResult Register(RegisterViewModel model)
        {
            var emailReg = @"^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$";

            if (string.IsNullOrEmpty(model.Email))
            {
                return(Json("nullEmail", JsonRequestBehavior.AllowGet));
            }
            if (string.IsNullOrEmpty(model.Password) || string.IsNullOrEmpty(model.ConfirmPassword))
            {
                return(Json("nullPassword", JsonRequestBehavior.AllowGet));
            }
            if (model.Password != model.ConfirmPassword)
            {
                return(Json("passwordError", JsonRequestBehavior.AllowGet));
            }
            if (!Regex.IsMatch(model.Email, emailReg))
            {
                return(Json("emailInvalid", JsonRequestBehavior.AllowGet));
            }
            if (userManagementService.IsExistName(model.Email))
            {
                return(Json("userExist", JsonRequestBehavior.AllowGet));
            }
            var domainModel = model.CovertoDomain();
            var result      = userManagementService.Register(domainModel);

            if (result)
            {
                return(Json("success", JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json("failed", JsonRequestBehavior.AllowGet));
            }
        }