Пример #1
0
        public ActionResult registerUser(string firstName,
                                         string lastName,
                                         string nickName,
                                         string dateOfBirth,
                                         string role,
                                         string userName,
                                         string password)
        {
            int valid = 1;
            var Jcon  = new JsonContainer();
            var objUserAccountHelper = new UserAccountHelper();

            if (objUserAccountHelper.VerifyUserName(userName))
            {
                Jcon.Result = -1;
                return(Json(Jcon));
            }

            DateTime date;

            if (!DateTime.TryParse(dateOfBirth, out date))
            {
                Jcon.Result = 0;
                return(Json(Jcon));
            }

            var userDetails = new UserAccount
            {
                firstName   = firstName,
                lastName    = lastName,
                nickName    = nickName,
                dateOfBirth = date,
                role        = role,
                userName    = userName,
                password    = password
            };

            try
            {
                objUserAccountHelper.InsertUserDetails(userDetails);
            }
            catch (Exception ex)
            {
                valid = 0;
            }

            Jcon.Result = valid;
            return(Json(Jcon));
        }