public ActionResult DeleteUserInfo(string userid)
 {
     UserModels user = new UserModels();
     bool result = user.DeleteUser(userid);
     var jsonResult = Json(result ? "{ result: success}" : "{ result: failure}", JsonRequestBehavior.AllowGet);
     return jsonResult;
 }
        public IActionResult Delete(string userName)
        {
            IActionResult response   = null;
            string        mess       = string.Empty;
            UserModels    userModels = new UserModels();

            User     cuser    = userModels.GetUserbyUserName(userName);
            UserInfo userInfo = userModels.GetUserInforByEmail(userName);

            if (cuser != null)
            {
                //// delete user
                bool rt = userModels.DeleteUser(userName);

                if (rt)
                {
                    //// delete avatar file
                    if (!string.IsNullOrEmpty(userInfo.Avatar) && userInfo.Avatar.Contains("/"))
                    {
                        string webRootPath = _hostingEnvironment.WebRootPath;
                        string fileDelete  = Path.Combine(webRootPath, userInfo.Avatar.Replace("/", "\\"));
                        if (System.IO.File.Exists(fileDelete))
                        {
                            System.IO.File.Delete(fileDelete);
                        }

                        string fileDelete2 = Path.Combine(webRootPath, userInfo.Avatar.Replace("/", "\\").Replace("sc_small_", "sc_full_"));
                        if (System.IO.File.Exists(fileDelete2))
                        {
                            System.IO.File.Delete(fileDelete2);
                        }
                    }

                    response = Json(new { code = Constant.Success, message = Constant.MessageDeleteCompleted });
                }
                else
                {
                    response = Json(new { code = Constant.Fail, message = Constant.MessageDeleteUncompleted });
                }
            }
            else
            {
                response = Json(new { code = Constant.NotExist, message = Constant.MessageNotExist });
            }

            return(response);
        }