public ActionResult User(int?cId, int?fId) { var objUserBal = new UsersBal(); var corporateId = Convert.ToInt32(cId) > 0 ? Convert.ToInt32(cId) : Helpers.GetSysAdminCorporateID(); var facilityId = Convert.ToInt32(fId) > 0 ? Convert.ToInt32(fId) : Helpers.GetDefaultFacilityId(); if (fId == 0 && !Helpers.GetLoggedInUserIsAdmin()) { facilityId = Helpers.GetDefaultFacilityId(); } var objUsersView = new UsersView { CurrentUser = new UsersCustomModel { CurrentUser = new Users { IsActive = true, CorporateId = corporateId, FacilityId = facilityId } }, UsersList = objUserBal.GetUsersByCorporateIdFacilityId(corporateId, facilityId), }; return(View(objUsersView)); }
public PartialViewResult RebindUsersList(int cId, int fId) { using (var objUserBal = new UsersBal()) { if (fId == 0 && !Helpers.GetLoggedInUserIsAdmin()) { fId = Helpers.GetDefaultFacilityId(); } var list = objUserBal.GetUsersByCorporateIdFacilityId(cId, fId); return(PartialView("UserControls/_UsersList", list)); } }
public ActionResult AddUser(Users objUser, int roleId, int cId, int fId) { using (var objUserBal = new UsersBal()) { if (fId == 0 && !Helpers.GetLoggedInUserIsAdmin()) { fId = Helpers.GetDefaultFacilityId(); } cId = cId == 0 ? Helpers.GetSysAdminCorporateID() : cId; var userId = Helpers.GetLoggedInUserId(); var currentDateTime = Helpers.GetInvariantCultureDateTime(); if (objUser.UserID > 0) { objUser.ModifiedBy = userId; objUser.ModifiedDate = currentDateTime; } else { objUser.CreatedBy = userId; objUser.CreatedDate = currentDateTime; } objUserBal.AddUpdateUser(objUser, roleId); //start var auditlogbal = new AuditLogBal(); var auditlogObj = new AuditLog { AuditLogID = 0, UserId = userId, CreatedDate = Helpers.GetInvariantCultureDateTime(), TableName = "Users", FieldName = "Password", PrimaryKey = 0, OldValue = string.Empty, NewValue = string.Empty, CorporateId = cId, FacilityId = fId }; auditlogbal.AddUptdateAuditLog(auditlogObj); var list = objUserBal.GetUsersByCorporateIdFacilityId(cId, fId); return(PartialView(PartialViews.UsersList, list)); } }
//public ActionResult AddRoleWithUser(int userID, int roleID) //{ // var objUserRoleBal = new UserRoleBal(); // var isExist = objUserRoleBal.CheckIfExists(userID, roleID); // if (!isExist) // { // var lstUserRoles = new List<UserRole> // { // new UserRole // { // UserID = userID, // RoleID = roleID, // IsActive = true, // IsDeleted = false, // CreatedBy = Helpers.GetLoggedInUserId(), // CreatedDate = Helpers.GetInvariantCultureDateTime() // } // }; // return Json(objUserRoleBal.AddUpdateUserRole(lstUserRoles)); // } // return Json(0); //} /// <summary> /// Adds the role with user. /// </summary> /// <returns></returns> /// <summary> /// Deletes the user. /// </summary> /// <param name="userId">The user identifier.</param> /// <param name="cId"></param> /// <param name="fId"></param> /// <returns></returns> public ActionResult DeleteUser(int userId, int cId, int fId) { var objUserBal = new UsersBal(); var objUser = objUserBal.GetUserById(userId); objUser.IsDeleted = true; objUser.DeletedBy = Helpers.GetLoggedInUserId(); objUser.DeletedDate = Helpers.GetInvariantCultureDateTime(); //To Do change it to server datetime objUser.TokenExpiryDate = null; objUser.UserToken = null; objUserBal.AddUpdateUser(objUser, 0); cId = cId == 0 ? Helpers.GetSysAdminCorporateID() : cId; if (fId == 0 && !Helpers.GetLoggedInUserIsAdmin()) { fId = Helpers.GetDefaultFacilityId(); } var list = objUserBal.GetUsersByCorporateIdFacilityId(cId, fId); return(PartialView("UserControls/_UsersList", list)); }