Пример #1
0
        public JsonResult AddNewUserApps()
        {
            string        _status = MyEnums.enumStatus.SUCCESS.ToString();
            int           result  = 0;
            UserAppsModel usrMdl  = new UserAppsModel();

            if (Request.Form["Id"] == "")
            {
                usrMdl.UserName    = Request.Form["UserName"].ToString();
                usrMdl.Password    = Request.Form["Password"].ToString();
                usrMdl.EmployeeId  = Convert.ToInt32(Request.Form["Employee"].ToString());
                usrMdl.IsExpired   = Convert.ToBoolean(Request.Form["IsExpired"].ToString());
                usrMdl.CreatedBy   = "SYSTEM";
                usrMdl.CreatedDate = DateTime.Now;
                result             = new UserMgmtBLL().ValidateBeforSave(usrMdl, out _status);
            }
            else
            {
                usrMdl.UserName     = Request.Form["UserName"].ToString();
                usrMdl.Id           = Convert.ToInt32(Request.Form["Id"].ToString());
                usrMdl.EmployeeId   = Convert.ToInt32(Request.Form["Employee"].ToString());
                usrMdl.IsExpired    = Convert.ToBoolean(Request.Form["IsExpired"].ToString());
                usrMdl.ModifiedBy   = "SYSTEM";
                usrMdl.ModifiedDate = DateTime.Now;
                result = new UserMgmtBLL().Update(usrMdl, out _status);
            }

            return(Json(new { Status = _status, Result = result }, JsonRequestBehavior.AllowGet));
        }
Пример #2
0
        public JsonResult ListActiveUser()
        {
            IEnumerable <UserAppsModel> lsuser = new List <UserAppsModel>();

            lsuser = new UserMgmtBLL().ListActiveUser();
            var JsonResult = Json(new { Data = lsuser }, JsonRequestBehavior.AllowGet);

            JsonResult.MaxJsonLength = Int32.MaxValue;
            return(JsonResult);
        }
Пример #3
0
        public JsonResult FindById(string id)
        {
            UserAppsModel mdl = new UserAppsModel();

            if (id != "")
            {
                mdl = new UserMgmtBLL().FindById(Convert.ToInt32(id));
            }

            return(Json(new { Id = mdl.Id, UserName = mdl.UserName, IsExpired = mdl.IsExpired, EmployeeId = mdl.EmployeeId }, JsonRequestBehavior.AllowGet));
        }
Пример #4
0
        public ActionResult Authenticate(FormCollection fc)
        {
            string        _userName = fc["UserName"];
            string        _password = fc["Password"];
            string        mesg      = string.Empty;
            UserAppsModel usr       = new UserAppsModel();

            if (_userName == "admin" && _password == "admin")
            {
                usr.UserName         = "******";
                usr.EmployeeId       = 999;
                usr.EmployeeName     = "super admin";
                usr.IsExpired        = false;
                Session["UserLogOn"] = usr;
                Session["UserProps"] = "admin;admin";
                FormsAuthentication.SetAuthCookie(usr.UserName, true);
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                usr = new UserMgmtBLL().Authenticate(_userName, _password, out mesg);
                if (mesg == string.Empty)
                {
                    if (usr.Id > 0)
                    {
                        Session["UserLogOn"] = usr;
                        Session["UserProps"] = usr.EmployeeName + ";" + Common.GetRoleAppsName(usr.Role);
                        FormsAuthentication.SetAuthCookie(usr.UserName, true);
                        return(RedirectToAction("Index", "Home"));
                    }
                    else
                    {
                        ViewBag.ErrMsg = "You are not recognized";
                        return(View("Login"));
                    }
                }
                else
                {
                    ViewBag.ErrMsg = mesg;
                    return(View("Login"));
                }
            }
        }
Пример #5
0
        public JsonResult ChangeUserPassword()
        {
            string _status      = MyEnums.enumStatus.SUCCESS.ToString();
            string _message     = string.Empty;
            int    result       = 0;
            string _oldPassword = Request.Form["OldPassword"];
            string _newPassword = Request.Form["NewPassword"];

            if (Session["UserLogOn"] != null)
            {
                result = new UserMgmtBLL().UpdateUserPassword(Utilities.GetUserNameLogon((UserAppsModel)Session["UserLogOn"]), _oldPassword, _newPassword, out _message);
                if (result <= 0 || _message != string.Empty)
                {
                    _status = MyEnums.enumStatus.ERROR.ToString();
                }
            }

            return(Json(new { Status = _status, Mesg = _message }, JsonRequestBehavior.AllowGet));
        }
Пример #6
0
        public JsonResult RemoveUserApps(string id)
        {
            string _status         = MyEnums.enumStatus.SUCCESS.ToString();
            int    result_affected = 0;

            try
            {
                if (id != "")
                {
                    result_affected = new UserMgmtBLL().Delete(Convert.ToInt32(id), out _status);
                    if (result_affected <= 0)
                    {
                        _status = "An Error occured when delete user application";
                    }
                }
            }
            catch (Exception ex)
            {
                _status = ex.Message;
            }
            return(Json(new { Status = _status, Result = result_affected }, JsonRequestBehavior.AllowGet));
        }
Пример #7
0
 public VideoCheckService()
 {
     BLLMovie = MovieMgmtBLL.getInstance();
     BLLOrder = OrderMgmtBLL.getInstance();
     BLLUser  = UserMgmtBLL.getInstance();
 }