Ejemplo n.º 1
0
        //Update User Details
        public JsonResult UpdateUser(User User)
        {
            string msg;

            if (ModelState.IsValid)
            {
                try
                {
                    String vNewSha1 = "";
                    if (User.Pwd != null)
                    {
                        String vNew = User.Pwd;
                        vNewSha1 = Crypto.SHA1(vNew);
                        string str = vNewSha1;
                        vNewSha1 = UserBL.Puz1(vNewSha1, User.EmailAdd);
                        byte[] bytes = UTF8Encoding.ASCII.GetBytes(str);
                        string str2  = UTF8Encoding.ASCII.GetString(bytes);
                    }


                    //if password is updated
                    if (UserBL.UpdateUser(new User {
                        ID = User.ID, FirstName = User.FirstName, SurName = User.SurName, EmailAdd = User.EmailAdd, UserLevel = User.UserLevel, AutoEmailAlert = User.AutoEmailAlert, Mobileno = User.Mobileno, Disabled = User.Disabled, Pwd = (User.Pwd == "" || User.Pwd == null) ? "" : vNewSha1, site = User.site
                    }) > 0)
                    {
                        UserBL.InsertRole(new User {
                            ID = User.ID, UserRole = User.UserRole
                        });
                        return(Json(new { isError = "F", message = "User details has been updated!" }));
                    }
                    else
                    {
                        return(Json(new { isError = "T", message = "Could not update data" }));
                    }
                }
                catch (Exception ex)
                {
                    return(Json(new { isError = "T", message = "Could not update data." }));
                }
            }
            else
            {
                //msg = "Sorry! Validation Error";
                return(Json(new { isError = "T", message = "Validation Error." }));
            }
        }