/// <summary> /// 会员登录 /// </summary> /// <param name="userName"></param> /// <param name="password"></param> /// <returns></returns> public UserStatusEnum Login(string userName, string password) { UserStatusEnum result = UserStatusEnum.NoExist; string encryptedValue = StringHelper.MD5(password); if (password.Length == 32) { encryptedValue = password; } var entity = _repository.Get(p => p.UserName == userName && p.UserPassword == encryptedValue); if (entity == null || entity.UserID <= 0) { return(result); } switch ((UserStatusEnum)entity.UserStatus) { case UserStatusEnum.None: entity.LoginTimes++; entity.LoginTime = new DateTime?(DateTime.Now); entity.LoginIP = Utility.GetClientIP(); entity.LastPassword = DataSecurity.MakeRandomString(10); _repository.Update(entity); result = UserStatusEnum.None; break; default: result = (UserStatusEnum)entity.UserStatus; break; } return(result); }
public async Task SetUserStatusAsync(int userId, UserStatusEnum userStatus) { using (UserDefinitionDataProvider userDP = new UserDefinitionDataProvider()) { UserDefinition user = await userDP.GetItemByUserIdAsync(userId); if (user == null) { throw new InternalError($"Unknown user (user id {userId})"); } if (user.UserStatus != userStatus) { user.UserStatus = userStatus; if (userStatus == UserStatusEnum.Approved) { user.LoginFailures = 0; } UpdateStatusEnum status = await userDP.UpdateItemAsync(user); if (status != UpdateStatusEnum.OK) { throw new InternalError($"Unexpected status {status} updating user account in {nameof(SetUserStatusAsync)}"); } } } }
public UserStatus(UserStatusEnum _Status, int _gameid, int _RoomID, int _UserID) { Status = _Status; RoomID = _RoomID; UserID = _UserID; Gameid = _gameid; }
/// <summary> /// ユーザ情報を追加/更新する /// </summary> /// <param name="boardId">ボードID</param> /// <param name="userName">ユーザ名</param> /// <param name="status">Kptステータス</param> public async Task UpsertUserAsync(int boardId, string userName, UserStatusEnum status) { CloudTable table = this.Client.GetTableReference(TblUser); var emp = new UserEntity(boardId, userName, status); TableOperation insertOp = TableOperation.InsertOrReplace(emp); await table.ExecuteAsync(insertOp); }
// 冻结或者解冻用户账号 public void UserFreeze(int unifiedAccountId, UserStatusEnum userStatus) { try { var paramDic = new Dictionary <string, object> { { "FunctionName", "UserFreeze" }, { "Parameters", new Dictionary <string, object> { { "id", unifiedAccountId }, { "UserStatus", userStatus } } } }; var paramJson = JsonConvert.SerializeObject(paramDic); var msgBytes = Encoding.UTF8.GetBytes(paramJson); var prop = new BasicProperties(); prop.ContentType = "application/json"; prop.ContentEncoding = "UTF-8"; IBasicProperties replyProp = new BasicProperties(); var responseBytes = this.Call(prop, msgBytes, out replyProp); var responseStr = Encoding.UTF8.GetString(responseBytes); // 记录日志 _log.Debug($"冻结或者解冻用户账号\n\trequest parameter: {paramJson} \n\tresponse message: {responseStr}"); } catch (System.Exception ex) { _log.Error(ex); } }
// GET: ManagementCenter/User public ActionResult Index(Guid?department = null, UserStatusEnum status = UserStatusEnum.All, string keywords = "") { var userDTO = _IUserService.GetUsers(department, status, keywords); ViewBag.keywords = keywords; ViewBag.department = department; this.DataBind(); return(View(userDTO)); }
public void MockObjectMustReturnExpectedEnum() { var mock = new Mock <IUserService>(); mock.Setup(x => x.MethodReturnsEnum()).Returns(UserStatusEnum.Active); UserStatusEnum value = mock.Object.MethodReturnsEnum(); Assert.Equal(UserStatusEnum.Active, value); }
/// <summary> /// 得到会员状态 /// </summary> /// <param name="userName"></param> /// <returns></returns> public UserStatusEnum GetUserStatus(string userName) { UserStatusEnum result = UserStatusEnum.NoExist; string strResult = _repository.GetScalar <string, int>(p => p.UserStatus.ToString(), p => p.UserName == userName); if (!string.IsNullOrEmpty(strResult)) { result = (UserStatusEnum)DataConverter.CLng(strResult, 16); } return(result); }
public async Task <List <WebUserItem> > WebGetUsers(UserStatusEnum userType, HRMAccessFilter filter) { IOrderedEnumerable <AuthUserEntity> list; switch (userType) { //case UserStatusEnum.Initial: //break; case UserStatusEnum.Awaiting: list = (await SQLHelper.GetAuthUsers()) .Where(a => a.IsPending && IsValidUserForInteraction(filter, a)) .OrderBy(a => a.Data.CharacterName); break; case UserStatusEnum.Authed: list = (await SQLHelper.GetAuthUsers((int)userType)) .Where(a => !a.IsAltChar && IsValidUserForInteraction(filter, a)) .OrderBy(a => a.Data.CharacterName); break; case UserStatusEnum.Dumped: list = (await SQLHelper.GetAuthUsers((int)userType)) .Where(a => IsValidUserForInteraction(filter, a)).OrderBy(a => a.Data.CharacterName); break; case UserStatusEnum.Spying: list = (await SQLHelper.GetAuthUsers((int)userType)) .Where(a => IsValidUserForInteraction(filter, a)).OrderBy(a => a.Data.CharacterName); break; case UserStatusEnum.Alts: list = (await SQLHelper.GetAuthUsers((int)userType)) .Where(a => a.IsAltChar && IsValidUserForInteraction(filter, a)) .OrderBy(a => a.Data.CharacterName); break; default: throw new ArgumentOutOfRangeException(nameof(userType), userType, null); } return(list.Select(a => new WebUserItem { Id = a.CharacterId, CharacterName = a.Data.CharacterName, CorporationName = a.Data.CorporationName, AllianceName = a.Data.AllianceName, CorporationTicker = a.Data.CorporationTicker, AllianceTicker = a.Data.AllianceTicker, RegDate = a.CreateDate, IconUrl = $"https://imageserver.eveonline.com/Character/{a.CharacterId}_64.jpg" }).ToList()); }
/// <summary> /// Updates user status /// </summary> /// <param name="userId"></param> /// <param name="userStatus"></param> /// <param name="updatedByUserId"></param> /// <returns>Returns number of affected rows.</returns> public int Execute(Guid userId, UserStatusEnum userStatus, Guid updatedByUserId) { // in parameters var parameters = new List<SqlParameter> { DbHelper.CreateParameter(Parameters.UserId, userId), DbHelper.CreateParameter(Parameters.UserStatusCode, userStatus.GetCode()), DbHelper.CreateParameter(Parameters.UpdatedByUserId, updatedByUserId), }; return DbHelper.ExecuteNonQueryCommand(this, parameters); }
public User SetDataFromDatabase(string id, string name, string email, IList<Service> servicesList, UserStatusEnum status, DateTime createTime) { this.CleanModel(); this.Id = id; this.Name = name; this.Email = email; this.ServicesList = servicesList; this.Status = status; this.CreateTime = createTime; return this; }
public List <UserModel> GetProgramUsers(UserStatusEnum userStatusEnum = UserStatusEnum.All) { var db = new TableBasedSp(RunSpName); var parameters = new Dictionary <string, string> { { "ProgramId", ProgramId.ToString() }, { "Enable", ((int)userStatusEnum).ToString() } }; var dt = db.GetFirstTableOfData("uspGetProgramUsers", ConnectionString, parameters); var users = new DataTableToList().Convert <UserModel>(dt); return(users); }
public User SetDataToCreate(string name, string email, IList<Service> servicesList, UserStatusEnum status) { this.CleanModel(); this.Name = name; this.Email = email; this.ServicesList = servicesList; this.Status = status; this.CreateTime = DateTime.UtcNow; this.ValidateDataToCreate(); return this; }
public UserDTOList GetUsers(Guid?department, UserStatusEnum status, string keywords = "", string order = "createddate_desc") { var userDTOList = new UserDTOList(); ISpecification <User> spec = Specification <User> .Eval(user => true); spec = new AndSpecification <User>(spec, Specification <User> .Eval(user => status == UserStatusEnum.All || user.Status == status)); spec = new AndSpecification <User>(spec, Specification <User> .Eval(user => (keywords == "") || user.UserName.Contains(keywords))); spec = new AndSpecification <User>(spec, Specification <User> .Eval(user => !(department.HasValue) || user.BranchId == department.Value)); this._IUserRepository.GetAll(spec).ToList().ForEach(item => userDTOList.Add(Mapper.Map <User, UserDTO>(item))); this.AppendUserInfo(userDTOList, this._IUserRepository.Data); return(userDTOList); }
/// <summary> /// 验证Cookies中的会员状态是否正常,不正常则清除Cookies。 /// </summary> /// <param name="context"></param> /// <returns></returns> public static async Task ValidateAsync(CookieValidatePrincipalContext context) { // Pull database from registered DI services. var appUsersService = context.HttpContext.RequestServices.GetRequiredService <IUsersServiceApp>(); var userPrincipal = context.Principal; // Look for the last changed claim. var userName = (from c in userPrincipal.Claims where c.Type == ClaimTypes.Name select c.Value).FirstOrDefault(); UserStatusEnum userStatusEnum = appUsersService.GetUserStatus(userName); if (string.IsNullOrEmpty(userName) || userStatusEnum != UserStatusEnum.None) { context.RejectPrincipal(); await context.HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); } }
public User SetDataToUpdate(string name = null, string email = null, IList<Service> servicesList = null, UserStatusEnum? status = null) { if (!string.IsNullOrEmpty(name)) this.Name = name; if (!string.IsNullOrEmpty(email)) this.Email = email; if (servicesList != null) this.ServicesList = servicesList; if (status != null && status.Value != UserStatusEnum.Undefined) this.Status = status.Value; this.ValidateDataToUpdate(); return this; }
public async Task <ActionResult> ChangeEmployeeUserStatus(string id, UserStatusEnum SelectedUserStatus) { AppUser currentUser = _context.Users.FirstOrDefault(c => c.Id == id); if (SelectedUserStatus == UserStatusEnum.Active) { currentUser.UserStatus = "Active"; } else { currentUser.UserStatus = "Inactive"; } //figure out if this is right _context.Update(currentUser); _context.SaveChanges(); //repopulate list of all customers List <AppUser> allEmployees = new List <AppUser>(); List <AppUser> members = new List <AppUser>(); List <AppUser> nonMembers = new List <AppUser>(); foreach (AppUser user in _userManager.Users) { var customerList = await _userManager.IsInRoleAsync(user, "Employee") ? members : nonMembers; customerList.Add(user); } RoleEditModel re = new RoleEditModel(); re.Members = members; foreach (var employee in re.Members) { allEmployees.Add(employee); } //return allCustomers; return(View("ManageEmployeeAccounts", allEmployees)); }
public int AddOrUpdateEventStatus(int customerId, UserStatusEnum status) { var first = _userStateRepository.Table.FirstOrDefault(c => c.CustomerId == customerId); if (first != null) { //Update first.Status = status; _userStateRepository.Update(first); } else { //Add new var item = new UserState { Status = status, CustomerId = customerId }; _userStateRepository.Insert(item); } return(_flowManagerService.GetStateId(status)); }
public static string ToString(UserStatusEnum val) { switch (val) { case UserStatusEnum.Created: { return("userStatus.created"); } case UserStatusEnum.Confirmed: { return("userStatus.confirmed"); } default: { return(null); } } }
protected User GetExistingUser(int id, int churchID, string name, string email, UserStatusEnum userStatus) { User user = null; try { user = Model.New<User>(); user.ID = id; user.EntityState = EntityStateEnum.Added; // Have to manually set this because we set the ID for User (otherwise the presence of the PK will cause the model to assume an update) user.ChurchID = churchID; user.Name = name; user.Email = email; user.UserStatusID = (int)UserStatusEnum.Active; user.SetDataContext(GetNewDataContext()); user.Save(); // We have to change the EntityState back to NotSet or else all Save operations will think we're always inserting. user.EntityState = EntityStateEnum.NotSet; } catch (Exception ex) { Assert.IsTrue(false, "Failed to create existing User in setup - " + ex.Message); } return user; }
public User(string email, string firstName, string lastName, string password, UserTypeEnum userType, UserStatusEnum status, bool tempPassword, AcquisitionEnum acquisition) : this() { logger.Debug("New Guid: " + this.Id); this.Email = email; this.FirstName = CryptoUtil.EncryptToBase64(firstName, this.Id); this.LastName = CryptoUtil.EncryptToBase64(lastName, this.Id); this.Password = CryptoUtil.EncryptToBase64(password, this.Id); this.UserType = userType; this.UpdatedTs = DateTime.UtcNow; this.Status = status; this.TempPassword = tempPassword; this.Acquisition = acquisition; }
public void ModifyUserStatusUpdatesStatus(UserStatusEnum userStatus) { // Arrange var userId = new Guid("00000000-0000-0000-0000-000000000001"); // Act userExtensionDao.ModifyUserSatus(userId, userStatus); // Assert var updatedUserExtension = userExtensionDao.GetByKey(userId); Assert.AreEqual(userStatus.GetCode(), updatedUserExtension.UserStatusCode, "UserStatusCode has not been updated"); }
public User SetDataFromDatabase(string id, string name, string email, IList <Service> servicesList, UserStatusEnum status, DateTime createTime) { this.CleanModel(); this.Id = id; this.Name = name; this.Email = email; this.ServicesList = servicesList; this.Status = status; this.CreateTime = createTime; return(this); }
public User SetDataToCreate(string name, string email, IList <Service> servicesList, UserStatusEnum status) { this.CleanModel(); this.Name = name; this.Email = email; this.ServicesList = servicesList; this.Status = status; this.CreateTime = DateTime.UtcNow; this.ValidateDataToCreate(); return(this); }
public UserStatus(UserStatusEnum userStatus) { Id = (int)userStatus; Name = userStatus.ToString(); }
public void AddUser(string email, string firstName, string lastName, string password, UserTypeEnum userType, UserStatusEnum status, bool tempPassword, AcquisitionEnum acquisition, List <string> groups, List <string> roles) { var user = new User(email, firstName, lastName, password, userType, status, true, acquisition); if (groups != null && groups.Any()) { user.AddUserGroup(groups); } if (roles != null && roles.Any()) { user.AddUserRole(roles); } this.CompanyAccesses.Add(new CompanyAccess { Company = this, User = user }); }
public UserStatusRef(UserStatusEnum userStatus) { Id = userStatus; Name = userStatus.GetDescription(); }
public UserStatusModel(UserStatusEnum userStatus) { Id = (int)userStatus; Name = EnumHelper.GetDescription(userStatus); }
public UserEntity(int boardId, string userName, UserStatusEnum userStatus) { PartitionKey = boardId.ToString(); RowKey = userName; this.UserStatus = (int)userStatus; }
/// <summary> /// Modifies user status /// </summary> /// <param name="userId"></param> /// <param name="userStatus"></param> /// <returns></returns> public bool ModifyUserSatus(Guid userId, UserStatusEnum userStatus) { var updatedByUserId = AuditFieldsHelper.GetUserId(); int rowsAffected = new StoredProcedures.Security.UpdateUserStatusMapper().Execute(userId, userStatus, updatedByUserId); if (rowsAffected == 0) { throw new ExpectedResultException(ErrorFactory.CreateAndLogError(Errors.SRVEX30027, "UserExtensionDao.ModifyUserSatus", additionalDescriptionParameters: new object[] { typeof(UserExtension).Name, userId }, arguments: new object[] { typeof(UserExtension).Name, userId } )); } return true; }
public static string GetUserStatusEnumStringValue(this UserStatusEnum enumValue) { return(enumValue.GetCustomEnumAttributeValue <StringValueAttribute, string>()); }
public void ModifyUserStatusCreatesRelatedEventType(UserStatusEnum userStatus, UserEventTypesEnum expectedUserEvent) { // Arrange var userId = new Guid("00000000-0000-0000-0000-000000000001"); string expectedUserEventCode = expectedUserEvent.GetCode(); var mockUserEventDao = MockRepository.GenerateMock<IUserEventDao>(); mockUserEventDao.Expect(u => u.Create(Arg<UserEvent>.Matches(ue => ue.UserEventType.Code == expectedUserEventCode))); var userManager = new UserManager(); userManager.UserEventDao = mockUserEventDao; userManager.UserExtensionDao = MockRepository.GenerateStub<IUserExtensionDao>(); // Act userManager.ModifyUserSatus(userId, userStatus, "notes"); // Assert mockUserEventDao.VerifyAllExpectations(); }
public async Task <Result> EditCitizenStatus(EditStatusViewModel EditStatusVM) { if (EditStatusVM.UserStatusEnum != UserStatusEnum.Normal) { // change user status var UserId = _context.Users.Where(u => u.Id == EditStatusVM.UserId).Select(u => u.Id).FirstOrDefault(); var oldStatus = _context.UserStatus.Where(u => u.UserId == EditStatusVM.UserId).OrderByDescending(u => u.Id).Select(u => u.UserStatusEnum).FirstOrDefault(); if (UserId != null) { if (oldStatus != EditStatusVM.UserStatusEnum) { UserStatus userStatus = new UserStatus(); userStatus.UserId = UserId; userStatus.UserStatusEnum = EditStatusVM.UserStatusEnum; userStatus.Date = DateTime.Now; userStatus.CreationDate = DateTime.Now; userStatus.IsActive = true; userStatus.CreatedBy = "test"; _context.UserStatus.Add(userStatus); _context.SaveChanges(); //change all checkedin shops in last 14 day satus to be suspected var checkedInPlacesLastTwoWeeks = _context.CheckInOut.Where(c => c.UserId == EditStatusVM.UserId && c.CheckInDate.Value.AddDays(14) > DateTime.Now).Select(c => c.ShopId).ToList(); var CheckInOutList = _context.CheckInOut.Where(c => c.UserId == EditStatusVM.UserId && c.CheckInDate.Value.AddDays(14) > DateTime.Now).ToList(); List <CheckInOutPeriod> CheckInOutPeriodList = new List <CheckInOutPeriod>(); foreach (var CheckInOut in CheckInOutList) { CheckInOutPeriod CheckInOutPeriod = new CheckInOutPeriod(); CheckInOutPeriod.CheckIn = CheckInOut.CheckInDate; CheckInOutPeriod.CheckOut = CheckInOut.CheckOutDate; CheckInOutPeriodList.Add(CheckInOutPeriod); } var CheckedInAtThisShops = _context.CheckInOut.Where(c => checkedInPlacesLastTwoWeeks.Contains(c.ShopId) && c.UserId != EditStatusVM.UserId).ToList(); List <string> userUdsForNotifications = new List <string>(); foreach (var CheckPeriod in CheckInOutPeriodList) { foreach (var usersCheckedIn in CheckedInAtThisShops) { if ((usersCheckedIn.CheckInDate < CheckPeriod.CheckOut && usersCheckedIn.CheckOutDate > CheckPeriod.CheckIn) || (usersCheckedIn.CheckInDate > CheckPeriod.CheckIn && CheckPeriod.CheckOut == null)) { UserStatus newUserStatus = new UserStatus(); newUserStatus.UserId = usersCheckedIn.UserId; newUserStatus.UserStatusEnum = UserStatusEnum.Suspected; newUserStatus.Date = DateTime.Now; newUserStatus.CreationDate = DateTime.Now; newUserStatus.IsActive = true; newUserStatus.CreatedBy = "test"; _context.UserStatus.Add(newUserStatus); _context.SaveChanges(); userUdsForNotifications.Add(usersCheckedIn.UserId); } } } List <long> NormalShopIds = new List <long>(); List <long> SuspectedShopIds = new List <long>(); List <long> InfectedShopIds = new List <long>(); // change shop status foreach (var checkedInShop in checkedInPlacesLastTwoWeeks) { var suspectedusersIds = _context.CheckInOut.Where(c => c.ShopId == checkedInShop).Select(c => c.UserId).Distinct().ToList(); List <UserStatusEnum> NoramlUsersStatesList = new List <UserStatusEnum>(); List <UserStatusEnum> SuspectedUsersStatesList = new List <UserStatusEnum>(); List <UserStatusEnum> InfectedUsersStatesList = new List <UserStatusEnum>(); foreach (var suspecteduserId in suspectedusersIds) { UserStatusEnum userLastStatus = _context.UserStatus.Where(u => u.UserId == suspecteduserId).OrderByDescending(u => u.Id).Select(u => u.UserStatusEnum).FirstOrDefault(); if (userLastStatus == UserStatusEnum.Normal) { NoramlUsersStatesList.Add(userLastStatus); } else if (userLastStatus == UserStatusEnum.Suspected) { SuspectedUsersStatesList.Add(userLastStatus); } else if (userLastStatus == UserStatusEnum.Infected) { InfectedUsersStatesList.Add(userLastStatus); } } if (NoramlUsersStatesList.Count() > (SuspectedUsersStatesList.Count() + InfectedUsersStatesList.Count())) { var shopStatus = _context.ShopStatus.Where(s => s.ShopId == checkedInShop).OrderByDescending(s => s.Id).Select(u => u.UserStatusEnum).FirstOrDefault(); if (shopStatus != UserStatusEnum.Normal) { ShopStatus NewShopStatus = new ShopStatus(); NewShopStatus.ShopId = checkedInShop; NewShopStatus.UserStatusEnum = UserStatusEnum.Normal; NewShopStatus.Date = DateTime.Now; NewShopStatus.CreationDate = DateTime.Now; NewShopStatus.IsActive = true; NewShopStatus.CreatedBy = "test"; _context.ShopStatus.Add(NewShopStatus); _context.SaveChanges(); NormalShopIds.Add(checkedInShop); } } else if (SuspectedUsersStatesList.Count() > NoramlUsersStatesList.Count()) { var shopStatus = _context.ShopStatus.Where(s => s.ShopId == checkedInShop).OrderByDescending(s => s.Id).Select(u => u.UserStatusEnum).FirstOrDefault(); if (shopStatus != UserStatusEnum.Suspected) { ShopStatus NewShopStatus = new ShopStatus(); NewShopStatus.ShopId = checkedInShop; NewShopStatus.UserStatusEnum = UserStatusEnum.Suspected; NewShopStatus.Date = DateTime.Now; NewShopStatus.CreationDate = DateTime.Now; NewShopStatus.IsActive = true; NewShopStatus.CreatedBy = "test"; _context.ShopStatus.Add(NewShopStatus); _context.SaveChanges(); SuspectedShopIds.Add(checkedInShop); } } //else if (InfectedUsersStatesList.Count() >= NoramlUsersStatesList.Count() || InfectedUsersStatesList.Count() >= SuspectedUsersStatesList.Count() || (((SuspectedUsersStatesList.Count() + InfectedUsersStatesList.Count()) > 0) && NoramlUsersStatesList.Count() == 0)) //{ // var shopStatus = _context.ShopStatus.Where(s => s.ShopId == checkedInShop).OrderByDescending(s => s.Id).Select(u => u.UserStatusEnum).FirstOrDefault(); // if (shopStatus != UserStatusEnum.Infected) // { // ShopStatus NewShopStatus = new ShopStatus(); // NewShopStatus.ShopId = checkedInShop; // NewShopStatus.UserStatusEnum = UserStatusEnum.Infected; // NewShopStatus.Date = DateTime.Now; // NewShopStatus.CreationDate = DateTime.Now; // NewShopStatus.IsActive = true; // NewShopStatus.CreatedBy = "test"; // _context.ShopStatus.Add(NewShopStatus); // _context.SaveChanges(); // InfectedShopIds.Add(checkedInShop); // } //} } #region SendNotification For Infected User //send notifications var title = Resources.MedicalStatusAlertTitle; var body = Resources.MedicalStatusIsChanged + " " + EditStatusVM.UserStatusEnum + " " + Resources.PleaseQuarantineYourSelf; PayLoadViewModel payLoadData = new PayLoadViewModel { InfectedUserName = "******", Title = title, Body = body }; var TokensList = GetUserToken(EditStatusVM.UserId); FirebaseHelper.SendNotification(TokensList, title, body, payLoadData); #endregion #region SendNotification For Suspected Users //send notifications var titleForSuspected = Resources.MedicalStatusAlertTitle; var bodyForSuspected = Resources.MedicalStatusIsChanged + " " + Resources.ContactedWithInfectedPerson; PayLoadViewModel payLoadDataForSuspected = new PayLoadViewModel { InfectedUserName = "******", Title = titleForSuspected, Body = bodyForSuspected }; var TokensListForSuspected = GetUsersTokens(userUdsForNotifications); FirebaseHelper.SendNotification(TokensListForSuspected, titleForSuspected, bodyForSuspected, payLoadDataForSuspected); #endregion #region SendNotification For Normal Shops if (NormalShopIds != null && NormalShopIds.Count() > 0) { var titleForShop = Resources.MedicalStatusAlertTitle; var bodyForNormalShop = Resources.TruststatusIsNormal; PayLoadViewModel payLoadDataForNormalShop = new PayLoadViewModel { InfectedUserName = "******", Title = titleForShop, Body = bodyForNormalShop }; var TokensListForNormalShops = GetShopsTokens(NormalShopIds); FirebaseHelper.SendNotification(TokensListForNormalShops, titleForShop, bodyForNormalShop, payLoadDataForNormalShop); } #endregion #region SendNotification For Suspected Shops if (SuspectedShopIds != null && SuspectedShopIds.Count() > 0) { var titleForShop = Resources.MedicalStatusAlertTitle; var bodyForSuspectedShops = Resources.InfectedPersonVisitStore; PayLoadViewModel payLoadDataForSuspectedShops = new PayLoadViewModel { InfectedUserName = "******", Title = titleForShop, Body = bodyForSuspectedShops }; var TokensListForSuspectedShops = GetShopsTokens(SuspectedShopIds); FirebaseHelper.SendNotification(TokensListForSuspectedShops, titleForShop, bodyForSuspectedShops, payLoadDataForSuspectedShops); } #endregion //#region SendNotification For Infected Shops //if (InfectedShopIds != null && InfectedShopIds.Count() > 0) //{ // var titleForShop = Resources.MedicalStatusAlertTitle; // var bodyForInfectedShops = Resources.InfectedPersonVisitStore; // PayLoadViewModel payLoadDataForInfectedShops = new PayLoadViewModel // { // InfectedUserName = "******", // Title = titleForShop, // Body = bodyForInfectedShops // }; // var TokensListForInfectedShops = GetShopsTokens(InfectedShopIds); // FirebaseHelper.SendNotification(TokensListForInfectedShops, titleForShop, bodyForInfectedShops, payLoadDataForInfectedShops); //} //#endregion return(new Result() { IsSuccess = true, Errors = new List <string>() }); } else { return(new Result() { IsSuccess = false, Errors = new List <string> { Resources.UserIsAlreadyOnThisStatus } }); } } else { return(new Result() { IsSuccess = false, Errors = new List <string> { Resources.UserNotExist } }); } } else { // change user status var UserId = _context.Users.Where(u => u.Id == EditStatusVM.UserId).Select(u => u.Id).FirstOrDefault(); var oldStatus = _context.UserStatus.Where(u => u.UserId == EditStatusVM.UserId).OrderByDescending(u => u.Id).Select(u => u.UserStatusEnum).FirstOrDefault(); if (UserId != null) { if (oldStatus != UserStatusEnum.Normal) { UserStatus userStatus = new UserStatus(); userStatus.UserId = UserId; userStatus.UserStatusEnum = EditStatusVM.UserStatusEnum; userStatus.Date = DateTime.Now; userStatus.CreationDate = DateTime.Now; userStatus.IsActive = true; userStatus.CreatedBy = "test"; _context.UserStatus.Add(userStatus); _context.SaveChanges(); #region SendNotification For Normal User //send notifications var title = Resources.MedicalStatusAlertTitle; var body = Resources.MedicalStatusIsChanged + " " + EditStatusVM.UserStatusEnum; PayLoadViewModel payLoadData = new PayLoadViewModel { InfectedUserName = "******", Title = title, Body = body }; var TokensList = GetUserToken(EditStatusVM.UserId); FirebaseHelper.SendNotification(TokensList, title, body, payLoadData); #endregion } else { return(new Result() { IsSuccess = false, Errors = new List <string> { Resources.UserIsAlreadyOnThisStatus } }); } } else { return(new Result() { IsSuccess = false, Errors = new List <string> { Resources.UserNotExist } }); } return(new Result() { IsSuccess = true, Errors = new List <string>() }); } }
public int GetStateId(UserStatusEnum status) { return(ApprovalSteps.First().Index); }
public UserStatusDomainModel(UserStatusEnum statusEnum) { Id = (int)statusEnum; Name = statusEnum.ToString(); }
public ApplicationUser() { CreatedAt = DateTime.Now; UpdatedAt = DateTime.Now; UserStatus = UserStatusEnum.Active; }
/// <summary> /// Modify User Status /// </summary> /// <param name="userId">id of user to modify</param> /// <param name="userStatus">new status for the user</param> /// <param name="notes">notes about the status change</param> public bool ModifyUserSatus(Guid userId, UserStatusEnum userStatus, string notes) { if (string.IsNullOrEmpty(notes)) { throw new ValidationException(ErrorFactory.CreateAndLogError(Errors.SRVEX30051, "Membership.ModifyUserSatus")); } using (var btx = new BusinessTransaction()) { UserEventTypesEnum eventType = userStatus == UserStatusEnum.Disabled ? UserEventTypesEnum.UserDisabled : UserEventTypesEnum.UserEnabled; userExtensionDao.ModifyUserSatus(userId, userStatus); RecordUserEvent(userId, eventType, notes); btx.Commit(); } return true; }
public async Task <List <WebUserItem> > WebGetUsers(UserStatusEnum userType, HRMAccessFilter filter) { IOrderedEnumerable <AuthUserEntity> list; switch (userType) { //case UserStatusEnum.Initial: //break; case UserStatusEnum.Awaiting: list = (await SQLHelper.GetAuthUsers()) .Where(a => a.IsPending && IsValidUserForInteraction(filter, a)) .OrderBy(a => a.Data.CharacterName); break; case UserStatusEnum.Authed: list = (await SQLHelper.GetAuthUsers((int)userType)) .Where(a => !a.IsAltChar && IsValidUserForInteraction(filter, a)) .OrderBy(a => a.Data.CharacterName); break; case UserStatusEnum.Dumped: list = (await SQLHelper.GetAuthUsers((int)userType)) .Where(a => IsValidUserForInteraction(filter, a)).OrderBy(a => a.Data.CharacterName); break; case UserStatusEnum.Spying: list = (await SQLHelper.GetAuthUsers((int)userType)) .Where(a => IsValidUserForInteraction(filter, a)).OrderBy(a => a.Data.CharacterName); break; case UserStatusEnum.Alts: list = (await SQLHelper.GetAuthUsers((int)userType)) .Where(a => a.IsAltChar && IsValidUserForInteraction(filter, a)) .OrderBy(a => a.Data.CharacterName); break; default: throw new ArgumentOutOfRangeException(nameof(userType), userType, null); } var result = new List <WebUserItem>(); foreach (var a in list) { bool invalidToken = false; if (a.HasToken && SettingsManager.Settings.HRMModule.ValidateTokensWhileLoading) { var token = await APIHelper.ESIAPI.RefreshToken(a.RefreshToken, SettingsManager.Settings.WebServerModule.CcpAppClientId, SettingsManager.Settings.WebServerModule.CcpAppSecret, $"From HRM | Char ID: {a.CharacterId} | Char name: {a.Data.CharacterName}"); invalidToken = token.Result == null; } result.Add(new WebUserItem { Id = a.CharacterId, CharacterName = a.Data.CharacterName, CorporationName = a.Data.CorporationName, AllianceName = a.Data.AllianceName, CorporationTicker = a.Data.CorporationTicker, AllianceTicker = a.Data.AllianceTicker, RegDate = a.CreateDate, IconUrl = $"https://imageserver.eveonline.com/Character/{a.CharacterId}_64.jpg", HasNoToken = !a.HasToken, HasInvalidToken = invalidToken }); } return(result); }