public JsonResult UnlockUser(long userID) { User admin = UserHelpers.GetCurrentAdmin(Session); if (admin == null) { return(Json(new { state = 0, error = "Require Signin", message = "You are not signed in..." })); } else { if (admin.AccountStatus != EventZoneConstants.LockedUser) { if (AdminDataHelpers.Instance.UnlockUser(admin.UserID, userID)) { return(Json(new { state = 1, error = "", message = "" })); } } } return(Json(new { state = 0, error = "Error", message = "Ops... Somthing went wrong! Please try again!", })); }
public ActionResult UnSetAdmin(long userID) { User admin = UserHelpers.GetCurrentAdmin(Session); if (admin == null) { return(Json(new { state = 0, error = "Require signin!", message = "You are not signed in..." })); } else if (admin.AccountStatus == EventZoneConstants.LockedUser) { return(Json(new { state = 0, error = "Locked account", message = "Your account is locked. You cant use this feature!" })); } else if (admin.UserRoles != EventZoneConstants.RootAdmin) { return(Json(new { state = 0, error = "Permission denied", message = "Only root admin can use this feature!" })); } if (admin.AccountStatus != EventZoneConstants.LockedUser) { User user = UserDatabaseHelper.Instance.GetUserByID(userID); if (user != null) { if (AdminDataHelpers.Instance.UnSetAdmin(admin.UserID, user.UserID)) { return(Json(new { state = 1, userID = userID })); } } } return(Json(new { state = 0, error = "Erorr", message = "Something wrong! Please try again!" })); }
public ActionResult RejectAppeal(long appealID) { User admin = UserHelpers.GetCurrentAdmin(Session); if (admin == null) { return(Json(new { state = 0, error = "Require signin!", message = "You are not signed in..." })); } else if (admin.AccountStatus == EventZoneConstants.LockedUser) { return(Json(new { state = 0, error = "Locked account", message = "Your account is locked. You cant use this feature!" })); } else if (admin.UserRoles != EventZoneConstants.RootAdmin && admin.UserRoles != EventZoneConstants.Admin) { return(Json(new { state = 0, error = "Permission denied", message = "This feature not avaiable for you!" })); } if (admin.AccountStatus != EventZoneConstants.LockedUser) { Appeal newAppeal = AdminDataHelpers.Instance.RejectAppeal(admin.UserID, appealID); if (newAppeal != null) { return(Json(new { state = 1, handleDate = newAppeal.SendDate.ToString(), handleBy = admin.UserName })); } } return(Json(new { state = 0, error = "Erorr", message = "Something wrong! Please try again!" })); }
public JsonResult ChangeUserEmail(long userID, string newEmail) { if (ModelState.IsValid) { User admin = UserHelpers.GetCurrentAdmin(Session); if (admin == null) { return(Json(new { state = 0, message = "You are not signed in..." })); } if (admin.AccountStatus != EventZoneConstants.LockedUser) { if (UserDatabaseHelper.Instance.GetUserByEmail(newEmail) != null) { return(Json(new { state = 0, error = "Email is exists", message = "This email already used in system! Please choose another!" })); } if (AdminDataHelpers.Instance.ChangeUserEmail(admin.UserID, userID, newEmail)) { return(Json(new { state = 1, userID = userID, newEmail = newEmail })); } } return(Json(new { state = 0, error = "Error", message = "somthing wrong! Please try again..." })); } else { return(Json(new { state = 0, erorr = " Wrong format", message = "Wrong email format! Please try again..." })); } }
public ActionResult SignIn() { User admin = UserHelpers.GetCurrentAdmin(Session); if (admin != null) { TempData["errorTittle"] = "Bad request"; TempData["errorMessage"] = "You are already signed in the system"; return(RedirectToAction("Index", "Admin")); } TempData["errorTitle"] = null; TempData["errorMessage"] = null; return(PartialView()); }
public ActionResult VerifyEvent(long eventID) { User admin = UserHelpers.GetCurrentAdmin(Session); if (admin == null) { return(Json(new { state = 0, error = "Require signin!", message = "You are not signed in..." })); } else if (admin.AccountStatus == EventZoneConstants.LockedUser) { return(Json(new { state = 0, error = "Locked account", message = "Your account is locked. You cant use this feature!" })); } else if (admin.UserRoles != EventZoneConstants.RootAdmin && admin.UserRoles != EventZoneConstants.Admin && admin.UserRoles != EventZoneConstants.Mod) { return(Json(new { state = 0, error = "Permission denied", message = "This feature not avaiable for you!" })); } if (admin.AccountStatus != EventZoneConstants.LockedUser) { Event evt = AdminDataHelpers.Instance.VerifyEvent(admin.UserID, eventID); if (evt != null) { return(Json(new { state = 1, })); } } return(Json(new { state = 0, error = "Erorr", message = "Something wrong! Please try again!" })); }
public JsonResult UnlockEvent(long eventID) { User admin = UserHelpers.GetCurrentAdmin(Session); if (admin == null) { return(Json(new { state = 0, error = "Require Signin", message = "You are not signed in..." })); } else { if (admin.AccountStatus != EventZoneConstants.LockedUser) { if (AdminDataHelpers.Instance.UnlockEvent(admin.UserID, eventID)) { NotificationDataHelpers.Instance.SendNotiUnLockEvent(EventDatabaseHelper.Instance.GetAuthorEvent(eventID).UserID, admin.UserID, eventID); return(Json(new { state = 1, error = "", message = "" })); } } } return(Json(new { state = 0, error = "Error", message = "Ops... Somthing went wrong! Please try again!", })); }
public ActionResult AddNewUserPost(UserCreatedByAdmin model) { User admin = UserHelpers.GetCurrentAdmin(Session); if (admin == null) { return(Json(new { state = 0, error = "Require signin!", message = "You are not signed in..." })); } else if (admin.AccountStatus == EventZoneConstants.LockedUser) { return(Json(new { state = 0, error = "Locked account", message = "Your account is locked. You cant use this feature!" })); } else if (admin.UserRoles != EventZoneConstants.RootAdmin && admin.UserRoles != EventZoneConstants.Admin) { return(Json(new { state = 0, error = "Permission denied", message = "This feature not avaiable for you!" })); } if (admin.AccountStatus != EventZoneConstants.LockedUser) { if (ModelState.IsValid) { User newUser = UserDatabaseHelper.Instance.GetUserByUserName(model.UserName); if (newUser != null) { //ModelState.AddModelError("", "UserName is already exist. Please choose another."); return(Json(new { state = 0, message = "UserName is already exist. Please choose another." })); } newUser = UserDatabaseHelper.Instance.GetUserByEmail(model.Email); if (newUser != null) { //ModelState.AddModelError("", "Email is already registered. Please choose another."); return(Json(new { state = 0, message = "Email is already registered. Please choose another." })); } User user = new User { UserEmail = model.Email, UserName = model.UserName, UserPassword = model.Password, UserDOB = model.UserDOB, UserFirstName = model.UserFirstName, DataJoin = DateTime.Today, AccountStatus = EventZoneConstants.ActiveUser, //set Active account Avartar = 10032, UserRoles = EventZoneConstants.User //set UserRole }; if (AdminDataHelpers.Instance.AddUser(user)) { UserDatabaseHelper.Instance.CreateUserChannel(user); return(Json(new { state = 1, userID = user.UserID })); } } } return(Json(new { state = 0, error = "Erorr", message = "Something wrong! Please try again!" })); }