public async Task SetInfoVisibilityAsync(Guid userId, InfoVisibility value) { var dictionary = await StateManager.GetOrAddAsync <IReliableDictionary <Guid, InfoVisibility> >(DictionaryName_InfoVisibility); using (var tx = StateManager.CreateTransaction()) { await dictionary.SetAsync(tx, userId, value); await tx.CommitAsync(); } }
public async Task <ActionResult <ResponseData> > SetInfoVisibility(InfoVisibility model) { try { var userId = GetUserId(); await _userSettingAppServiceFactory(userId).SetInfoVisibilityAsync(userId, model); return(BuildSuccess()); } catch (Exception ex) { return(BadRequest(LogError(_logger, ex))); } }
public async Task TestGetInfoVisibility() { var value = new InfoVisibility() { Mobile = true }; var userSettingAppService = Substitute.For <IUserSettingAppService>(); userSettingAppService.GetInfoVisibilityAsync(User_Id) .Returns(Task.FromResult(value)); var target = new UserSettingController(_ => userSettingAppService); target.ControllerContext = CreateMockContext(); var result = await target.GetInfoVisibility(); var data = result.Value; data.Should().BeOfType <InfoVisibility>(); data.Mobile.Should().BeTrue(); }
public async Task TestSetInfoVisibility() { var value = new InfoVisibility() { Mobile = true }; var userSettingAppService = Substitute.For <IUserSettingAppService>(); userSettingAppService.SetInfoVisibilityAsync(User_Id, value) .Returns(Task.CompletedTask); var target = new UserSettingController(_ => userSettingAppService); target.ControllerContext = CreateMockContext(); var result = await target.SetInfoVisibility(value); var data = result.Value; data.Should().BeOfType <ResponseData>(); data.Status.Should().Be(0); }