public IActionResult SignUp(string fullname, string email, string username, string password, string password2, string listRole) { List <MRole> lstRole = new List <MRole>(); string errMsg; MUser objMuser = new MUser() { FullName = fullname, Email = email, Username = username, Password = password, IsActive = true, IsLocked = false }; errMsg = ValidateUserData(objMuser, password, listRole, ref lstRole); if (errMsg == "") { MUserVM obju = new MUserVM(); obju.ListRole = new List <TuserRole>(); foreach (var role in lstRole) { obju.ListRole.Add(new TuserRole() { Username = username, RoleID = role.RoleID }); } obju.objUser = objMuser; errMsg = acc.Register(obju, password2); return(Z_Result.SetResult(errMsg)); } return(Z_Result.SetResult(errMsg)); }
public IActionResult SubmitDelete(string id) { string errMsg = string.IsNullOrEmpty(id) ? "RoleID can't be empty" : ""; if (errMsg == "") { id = id.ToUpper(); bool isDuplicate = rlm.CheckIsExist(id, ref errMsg); if (errMsg == "") { errMsg = !isDuplicate ? "Data does not exist" : ""; } else { logger_.ERROR(errMsg); errMsg = "Internal Server Error"; } } if (errMsg == "") { errMsg = rlm.Delete(id); if (!string.IsNullOrEmpty(errMsg)) { logger_.ERROR(errMsg); errMsg = "Internal Server Error"; } } return(Z_Result.SetResult(errMsg)); }
public IActionResult ReadListUser() { string mssg = ""; List <MUserVM> ret = acc.ReadListUser(ref mssg); return(Z_Result.SetResult(mssg, ret)); }
public IActionResult GetList() { string mssg = ""; List <MMenu> ret = mmgr.ReadList(ref mssg); return(Z_Result.SetResult(mssg, ret)); }
public IActionResult GetListRoleAccess() { string mssg = ""; List <TControllerRoleAccess> ret = prm.ReadListRoleAccess(ref mssg); return(Z_Result.SetResult(mssg, ret)); }
public IActionResult SubmitAdd(string obj) { MMenu obj_ = new MMenu(); string errMsg = Validate(obj, ref obj_); if (errMsg == "") { obj_.ID = obj_.ID.ToUpper(); bool isDuplicate = mmgr.CheckIsExist(obj_.ID, ref errMsg); if (errMsg == "") { errMsg = isDuplicate ? "Data Already Exist" : ""; } else { _logger.ERROR(errMsg); errMsg = "Internal Server Error"; } } if (errMsg == "") { errMsg = mmgr.Add(obj_); if (!string.IsNullOrEmpty(errMsg)) { _logger.ERROR(errMsg); errMsg = "Internal Server Error"; } } return(Z_Result.SetResult(errMsg)); }
public IActionResult SubmitUpdateRoleAccess(string obj) { TControllerRoleAccess objRoleAccess = new TControllerRoleAccess(); string errMsg = ValidateRoleAccess(obj, ref objRoleAccess); if (errMsg == "") { objRoleAccess.RoleID = objRoleAccess.RoleID.ToUpper(); bool isDuplicate = prm.CheckDuplicateRoleAccess(objRoleAccess.ControllerName, objRoleAccess.RoleID, ref errMsg); if (errMsg == "") { errMsg = !isDuplicate ? "Data is not exist" : ""; } else { errMsg = "Internal Server Error"; } } if (errMsg == "") { errMsg = prm.UpdateRoleAccess(objRoleAccess) != "" ? "Internal Server Error" : ""; } return(Z_Result.SetResult(errMsg)); }
public IActionResult GetListActionPermission(string controllerName) { string mssg = ""; List <TActionPermission> ret = prm.ReadListActionPermission(ref mssg, controllerName); return(Z_Result.SetResult(mssg, ret)); }
public IActionResult GetList() { string mssg = ""; List <MRole> ret = rlm.ReadList(ref mssg); return(Z_Result.SetResult(mssg, ret)); }
public IActionResult SubmitUpdate(string obj) { MRole obj_ = new MRole(); string errMsg = Validate(obj, ref obj_); if (errMsg == "") { bool isExist = rlm.CheckIsExist(obj_.RoleID, ref errMsg); if (errMsg == "") { errMsg = !isExist ? "Data does not exist" : ""; } else { logger_.ERROR(errMsg); errMsg = "Internal Server Error"; } } if (errMsg == "") { errMsg = rlm.Update(obj_); if (!string.IsNullOrEmpty(errMsg)) { logger_.ERROR(errMsg); errMsg = "Internal Server Error"; } } return(Z_Result.SetResult(errMsg)); }
public IActionResult Logout() { if (!string.IsNullOrEmpty(HttpContext.Session.GetString(Helpers.SessionKeyUser.Key))) { HttpContext.Session.Remove(Helpers.SessionKeyUser.Key); } return(Z_Result.SetResult("")); }
public IActionResult SubmitDelete(string password) { MUser objmuser = new MUser(); string objIdentity = HttpContext.Session.GetString(Helpers.SessionKeyUser.Key); if (!string.IsNullOrEmpty(objIdentity)) { objmuser.Username = JsonConvert.DeserializeObject <UserSessionModel>(objIdentity).username; } return(Z_Result.SetResult(acc.DeactiveAccount(objmuser.Username, password))); }
public IActionResult SubmitUpdateActionPermission(string obj) { List <TActionPermission> objActPermission = new List <TActionPermission>(); string errMsg = ValidateActPermission(obj, ref objActPermission); if (errMsg == "") { errMsg = prm.UpdateActPermission(objActPermission) != "" ? "Internal Server Error" : ""; } return(Z_Result.SetResult(errMsg)); }
public IActionResult Authenticate(string username, string password) { string errMsg; int? sessioninputTimes = HttpContext.Session.GetInt32(Helpers.SessionKeyUser.KeyOfInputPass); if (sessioninputTimes == null) { errMsg = string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password) ? "Username or Password can't be empty" : ""; HttpContext.Session.SetInt32(Helpers.SessionKeyUser.KeyOfInputPass, 1); } else { int?locked = HttpContext.Session.GetInt32(Helpers.SessionKeyUser.KeyOfLockedUser); if (locked == 1) { errMsg = "account is locked"; } else if (sessioninputTimes >= 5) { if (locked != 1) { HttpContext.Session.SetInt32(Helpers.SessionKeyUser.KeyOfLockedUser, 1); } errMsg = "incorrect username or pass 5 times"; } else { errMsg = string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password) ? "Username or Password can't be empty" : ""; HttpContext.Session.SetInt32(Helpers.SessionKeyUser.KeyOfInputPass, (int)sessioninputTimes + 1); } } if (errMsg == "") { MUserVM obj = acc.Login(username, password, out errMsg); if (errMsg == "") { HttpContext.Session.SetInt32(Helpers.SessionKeyUser.KeyOfInputPass, 0); MUser result = obj.objUser; UserSessionModel userSessionModel = new UserSessionModel(); userSessionModel.username = result.Username; userSessionModel.roleid = obj.ListRole; userSessionModel.fullname = result.FullName; HttpContext.Session.SetString(Helpers.SessionKeyUser.Key, JsonConvert.SerializeObject(userSessionModel)); HttpContext.Session.SetInt32(Helpers.SessionKeyUser.KeyOfInputPass, 0); } } return(Z_Result.SetResult(errMsg)); }
public IActionResult Error() { var exceptionFeature = HttpContext.Features.Get <IExceptionHandlerPathFeature>(); if (exceptionFeature != null) { ZLogger objLog = _logger.GetLogInfo; objLog.Path = exceptionFeature.Path; _logger.SetLogInfo(objLog); _logger.ERROR(exceptionFeature.Error.Message); } //TODO create error view return(Z_Result.SetResult("Internal Server Error", new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier })); }
public IActionResult SubmitRequestResetPassword(string email) { return(Z_Result.SetResult(acc.RequestForgotPassword(email))); }
public IActionResult SubmitNewPassword(string newPass, string newPass2, string Token) { return(Z_Result.SetResult(acc.ResetPassword(newPass, newPass2, Token))); }