// 重置密码 public void ResetPassword(string username) { Account account = GetOneAccount(AccountIdentifier.of(username)); account.PassWord = passwordService.CreateDbPassword("1"); Commit(); }
// 添加账户 public JsonResult CreateAccount() { var stream = new StreamReader(Request.InputStream); string str = stream.ReadToEnd(); JavaScriptSerializer js = new JavaScriptSerializer(); try { var datas = js.Deserialize <Dictionary <string, object> >(str); accountService.CreateAccount(datas[key.username].ToString(), datas[key.jobnumber].ToString()) .SetPassWord("1") .SetCanDelete(true); Account account = accountService.GetOneAccount(AccountIdentifier.of(datas[key.username].ToString())); List <string> roles = new List <string>((string[])((ArrayList)datas["roles"]).ToArray(typeof(string))); for (var i = 0; i < roles.Count; i++) { int role = (int)Enum.Parse(typeof(Role), roles[i]); account.AddRole(role); } accountService.Commit(); // 一个方法只能Commit一次 var result = new{ Result = "成功" }; return(Json(result, JsonRequestBehavior.DenyGet)); } catch (Exception err) { var result = new{ Result = err.Message }; return(Json(result, JsonRequestBehavior.DenyGet)); } }
public async Task Then_If_Employer_The_Accounts_Api_Is_Checked( string accountLegalEntityPublicHashedId, AccountDetail accountDetailApiResponse, List <GetEmployerAccountLegalEntityItem> legalEntities, [Frozen] Mock <IAccountsApiClient <AccountsConfiguration> > accountsApi, AccountLegalEntityPermissionService service) { var accountIdentifier = new AccountIdentifier("Employer-ABC123-Product"); legalEntities.First().AccountLegalEntityPublicHashedId = accountLegalEntityPublicHashedId; accountsApi .Setup(x => x.Get <AccountDetail>( It.Is <GetAllEmployerAccountLegalEntitiesRequest>(c => c.GetUrl.EndsWith($"accounts/{accountIdentifier.AccountHashedId}")))) .ReturnsAsync(accountDetailApiResponse); for (var i = 0; i < accountDetailApiResponse.LegalEntities.Count; i++) { var index = i; accountsApi .Setup(client => client.Get <GetEmployerAccountLegalEntityItem>( It.Is <GetEmployerAccountLegalEntityRequest>(request => request.GetUrl.Equals(accountDetailApiResponse.LegalEntities[index].Href)))) .ReturnsAsync(legalEntities[index]); } var actual = await service.GetAccountLegalEntity(accountIdentifier, accountLegalEntityPublicHashedId); actual.Name.Should().Be(legalEntities.First().AccountLegalEntityName); actual.AccountLegalEntityPublicHashedId.Should().Be(legalEntities.First().AccountLegalEntityPublicHashedId); actual.AccountHashedId.Should().Be(accountIdentifier.AccountHashedId); }
public MisskeyReplyNotification(AccountIdentifier accountIdentifier, string replyUserDisplayName, string replyUsername, string reply) : base(accountIdentifier) { ReplyUserDisplayName = replyUserDisplayName; ReplyUsername = replyUsername; Reply = reply; }
public MisskeySensitiveQuoteNotification(AccountIdentifier accountIdentifier, string quoteUserDisplayName, string quoteUsername, string quoteContent, string quoteCw) : base(accountIdentifier) { QuoteUserDisplayName = quoteUserDisplayName; QuoteUsername = quoteUsername; QuoteContent = quoteContent; QuoteCw = quoteCw; }
public MisskeyMentionNotification(AccountIdentifier accountIdentifier, string mentionUserDisplayName, string mentionUsername, string mention) : base(accountIdentifier) { MentionUserDisplayName = mentionUserDisplayName; MentionUsername = mentionUsername; Mention = mention; }
public MisskeyNote(AccountIdentifier accountIdentifier, string authorDisplayName, string authorUsername, string content) : base(accountIdentifier) { AuthorDisplayName = authorDisplayName; AuthorUsername = authorUsername; Content = content; }
//改 public IAccountCommand EditAccount(AccountIdentifier id) { var account = GetOneAccount(id); repository.Save(account); return(new AccountCommand(account, repository, passwordService)); }
public async Task <IActionResult> GetList([FromHeader(Name = "x-request-context-subscription-name")] string accountIdentifier) { try { var account = new AccountIdentifier(accountIdentifier); if (account.AccountType == AccountType.Provider && account.Ukprn == null) { return(new BadRequestObjectResult("Account Identifier is not in the correct format.")); } switch (account.AccountType) { case AccountType.Employer: var employerQueryResponse = await _mediator.Send(new GetLegalEntitiesForEmployerQuery { EncodedAccountId = account.AccountHashedId }); return(Ok((GetAccountLegalEntitiesListResponse)employerQueryResponse)); case AccountType.Provider: var providerQueryResponse = await _mediator.Send(new GetProviderAccountLegalEntitiesQuery { Ukprn = account.Ukprn.Value }); return(Ok((GetAccountLegalEntitiesListResponse)providerQueryResponse)); default: return(new StatusCodeResult((int)HttpStatusCode.Forbidden)); } } catch (Exception e) { _logger.LogError($"Unable to get account legal entities for {accountIdentifier}", e); return(new StatusCodeResult((int)HttpStatusCode.InternalServerError)); } }
public MastodonStatus(AccountIdentifier accountIdentifier, string authorDisplayName, string authorUsername, string content, IEnumerable <string>?mediaDescriptions = null) : base(accountIdentifier) { AuthorDisplayName = authorDisplayName; AuthorUsername = authorUsername; Content = content; MediaDescriptions = mediaDescriptions; }
public MisskeySensitiveNote(AccountIdentifier accountIdentifier, string authorDisplayName, string authorUsername, string content, string cw) : base(accountIdentifier) { AuthorDisplayName = authorDisplayName; AuthorUsername = authorUsername; Content = content; Cw = cw; }
public void UpdateAccountName(AccountIdentifier account) { logger.Log(LogLevel.Info, "updating to account {0} ", account); _userToken = _authorizationManager.GetUserAccountToken(_userName, account); SetLatestValuationDate(); _TradeUpdateCount = 0; UpdateTradeUpdateEvent(); }
public Account GetAccount(AccountIdentifier id) { if (!repository.IsExisted(new Account.By(id))) { throw new DomainErrorException("用户名不存在"); } return(repository.FindOne(new Account.By(id))); }
public void Then_If_No_Value_Supplied_Not_Known_Type_Returned() { var actual = new AccountIdentifier(null); actual.AccountType.Should().Be(AccountType.Unknown); actual.AccountHashedId.Should().BeNull(); actual.Ukprn.Should().BeNull(); }
public void Then_If_Not_Recognised_Format_Not_Known_Type_Returned(string accountIdentifier) { var actual = new AccountIdentifier(accountIdentifier); actual.AccountType.Should().Be(AccountType.Unknown); actual.AccountHashedId.Should().BeNull(); actual.Ukprn.Should().BeNull(); }
public void DeleteAccount(AccountIdentifier id) { if (id.UserName == "admin" || id.UserName == "TomorrowSoft") { throw new Exception("管理员不能删除"); } repository.Remove(GetAccount(id)); }
public MisskeySensitiveMentionNotification(AccountIdentifier accountIdentifier, string mentionUserDisplayName, string mentionUsername, string mention, string cw) : base(accountIdentifier) { MentionUserDisplayName = mentionUserDisplayName; MentionUsername = mentionUsername; Mention = mention; Cw = cw; }
public MisskeySensitiveReplyNotification(AccountIdentifier accountIdentifier, string replyUserDisplayName, string replyUsername, string reply, string cw) : base(accountIdentifier) { ReplyUserDisplayName = replyUserDisplayName; ReplyUsername = replyUsername; Reply = reply; Cw = cw; }
public MisskeyRenoteNotification(AccountIdentifier accountIdentifier, string authorDisplayName, string authorUsername, string content, string renoteUserDisplayName, string renoteUsername) : base(accountIdentifier) { AuthorDisplayName = authorDisplayName; AuthorUsername = authorUsername; Content = content; RenoteUserDisplayName = renoteUserDisplayName; RenoteUsername = renoteUsername; }
public void CreateAccountIdentifier() { var a1 = new AccountIdentifier { Pattern = new AmountPattern { Amount = 10M }, Account = _groceries }; var a2 = new AccountIdentifier { Pattern = new FieldPattern { Name = "Other Party", Pattern = "Blizzard" }, Account = _wow }; Assert.That(_row1.Object.IdentifyAccount(new[] { a1, a2 }), Is.EqualTo(_groceries)); Assert.That(_row2.Object.IdentifyAccount(new[] { a1, a2 }), Is.EqualTo(_wow)); Assert.That(_row3.Object.IdentifyAccount(new[] { a1, a2 }), Is.Null); }
public async Task DeleteAccount(string username, string instance, CancellationToken cancellationToken) { var id = new AccountIdentifier(new Username(username), new Instance(instance)); await _mastodonAccountRepository.DeleteMastodonAccount(id, cancellationToken); await _misskeyAccountRepository.DeleteMisskeyAccount(id, cancellationToken); _connectionRepository.StopConnection(id); }
public void Then_The_Fields_Are_Mapped_For_Provider(int ukprn) { var accountIdentifier = $"Provider-{ukprn}-Product"; var actual = new AccountIdentifier(accountIdentifier); actual.AccountType.Should().Be(AccountType.Provider); actual.Ukprn.Should().Be(ukprn); actual.AccountHashedId.Should().BeNull(); }
public void CreateSimpleIdentifier() { var identifier = new AccountIdentifier { Account = TestData.Bank, Pattern = new AmountPattern() { Amount = 100, Direction = EntryType.Credit } }; _repository.AddOrUpdate(identifier); }
public MastodonSensitiveMentionNotification(AccountIdentifier accountIdentifier, string authorDisplayName, string authorUsername, string spoilerText, string content, IEnumerable <string>?mediaDescriptions = null) : base(accountIdentifier) { AuthorDisplayName = authorDisplayName; AuthorUsername = authorUsername; SpoilerText = spoilerText; Content = content; MediaDescriptions = mediaDescriptions; }
public MastodonFavoriteNotification(AccountIdentifier accountIdentifier, string displayName, string favoriteUserDisplayName, string favoriteUserUsername, string content, IEnumerable <string>?mediaDescriptions = null) : base(accountIdentifier) { DisplayName = displayName; FavoriteUserDisplayName = favoriteUserDisplayName; FavoriteUserUsername = favoriteUserUsername; Content = content; MediaDescriptions = mediaDescriptions; }
/// <summary> /// Handle GetUserLimits API call /// </summary> /// <param name="context"></param> private void GetUserLimits(HttpContext context) { NameValueCollection parameters = context.Request.Params; List<string> limitType = new List<string>(); if(parameters["limitType"] != "") limitType.Add(parameters["limitType"]); AccountIdentifier accountId = new AccountIdentifier(); if (parameters["email"] != "") { accountId.email = parameters["email"]; } if (parameters["phoneCountry"] != "" && parameters["phoneNumber"] != "") { accountId.phone = new PhoneNumberType(parameters["phoneCountry"], parameters["phoneNumber"]); if (parameters["phoneExtension"] != "") accountId.phone.extension = parameters["phoneExtension"]; } GetUserLimitsRequest req = new GetUserLimitsRequest( new RequestEnvelope("en_US"), accountId, parameters["country"], parameters["currencyCode"], limitType); // All set. Fire the request AdaptivePaymentsService service = new AdaptivePaymentsService(); GetUserLimitsResponse resp = null; try { resp = service.GetUserLimits(req); } catch (System.Exception e) { context.Response.Write(e.Message); return; } // Display response values. Dictionary<string, string> keyResponseParams = new Dictionary<string, string>(); string redirectUrl = null; if (!(resp.responseEnvelope.ack == AckCode.FAILURE) && !(resp.responseEnvelope.ack == AckCode.FAILUREWITHWARNING)) { int idx = 1; foreach (UserLimit userLimit in resp.userLimit) { keyResponseParams.Add("Limit amount " + idx, userLimit.limitAmount.amount + userLimit.limitAmount.code); keyResponseParams.Add("Limit type " + idx, userLimit.limitType); idx++; } } displayResponse(context, "GetAvailableShippingAddresses", keyResponseParams, service.getLastRequest(), service.getLastResponse(), resp.error, redirectUrl); }
public void Then_Unknown_If_External_Id_Is_Not_In_Correct_Format(string externalId) { var accountIdentifier = $"External-{externalId}-Product"; var actual = new AccountIdentifier(accountIdentifier); actual.AccountType.Should().Be(AccountType.Unknown); actual.ExternalId.Should().BeEmpty(); actual.AccountHashedId.Should().BeNull(); actual.Ukprn.Should().BeNull(); }
public void Then_The_Null_Set_For_Ukprn_If_Not_In_Correct_Format() { var ukprn = "ABC123"; var accountIdentifier = $"Provider-{ukprn}-Product"; var actual = new AccountIdentifier(accountIdentifier); actual.AccountType.Should().Be(AccountType.Provider); actual.Ukprn.Should().BeNull(); actual.AccountHashedId.Should().BeNull(); }
public void Then_If_Not_Recognised_AccountType_Format_Not_Know_Type_Returned() { var accountId = "ABC123"; var accountIdentifier = $"Citizen-{accountId}-Product"; var actual = new AccountIdentifier(accountIdentifier); actual.AccountType.Should().Be(AccountType.Unknown); actual.AccountHashedId.Should().BeNull(); actual.Ukprn.Should().BeNull(); }
public void AddOrUpdate(AccountIdentifier identifier) { var document = _mappingEngine.Map<Documents.AccountIdentifier>(identifier); using ( var unitOfWork = _repository.DocumentStore.OpenSession() ) { unitOfWork.Store(document); unitOfWork.SaveChanges(); identifier.Id = document.Id; } }
public static void CreateAccount() { if (!repository.IsExisted(new Account.By(AccountIdentifier.of("admin")))) { accountService.CreateAccount("admin") .SetPassWord("1") .SetRole(Role.Admin) .SetCanDelete(false) .Commit(); } }
public MastodonSensitiveReblogNotification(AccountIdentifier accountIdentifier, string displayName, string reblogUserDisplayName, string reblogUserUsername, string spoilerText, string content, IEnumerable <string>?mediaDescriptions = null) : base(accountIdentifier) { DisplayName = displayName; ReblogUserDisplayName = reblogUserDisplayName; ReblogUserUsername = reblogUserUsername; SpoilerText = spoilerText; Content = content; MediaDescriptions = mediaDescriptions; }
public MisskeySensitiveReactionNotification(AccountIdentifier accountIdentifier, string authorDisplayName, string authorUsername, string content, string cw, string reactionUserDisplayName, string reactionUsername, string reaction) : base(accountIdentifier) { AuthorDisplayName = authorDisplayName; AuthorUsername = authorUsername; Content = content; Cw = cw; ReactionUserDisplayName = reactionUserDisplayName; ReactionUsername = reactionUsername; Reaction = reaction; }
public GetAccountIdentifierTests(AccountIdentifierRepository repository) { var identifier = new AccountIdentifier { Account = TestData.Bank, Pattern = new AmountPattern() { Amount = 100, Direction = EntryType.Credit } }; _repository = repository; _repository.AddOrUpdate(identifier); }
public void AddOrUpdate(AccountIdentifier identifier) { var models = identifier.Map<Models.AccountIdentifier>(); int id = _database.Execute("INSERT INTO [AccountIdentifier] (AccountId) OUTPUT inserted.id VALUES (@accountId)", new { models.AccountId }); foreach (var model in models.Patterns) { _database.Execute( "INSERT INTO [AccountIdentifierPattern] (AccountIdentifierId, Name, PropertiesJson) VALUES (@id, @name, @propertiesJson)", new { id, model.Name, model.PropertiesJson } ); } }
public void CreateCompositeIdentifier() { var identifier = new AccountIdentifier { Account = TestData.Bank, Pattern = new CompositePattern { new AmountPattern() { Amount = 100, Direction = EntryType.Credit }, new DayOfMonthPattern() { DaysOfMonth = new int[] { 1, 14 } } } }; _repository.AddOrUpdate(identifier); }
public void AccountIdentifierName() { var a1 = new AccountIdentifier { Pattern = new AmountPattern { Amount = 10M }, Account = _groceries }; Assert.That(a1.ToString(), Is.EqualTo("Groceries <- Amount=10.00")); }