public static async Task <UserInfoFlyout> CreateAsync(UserId userId) { var niconicoSession = Microsoft.Toolkit.Mvvm.DependencyInjection.Ioc.Default.GetService <NiconicoSession>(); var info = await niconicoSession.ToolkitContext.User.GetUserDetailAsync(userId); if (!info.IsSuccess) { return(null); } var user = info.Data.User; var flyout = new UserInfoFlyout() { UserId = user.Id, Nickname = user.Nickname, }; flyout.SetIcon(user.Icons.Small); var userFollowProvider = Microsoft.Toolkit.Mvvm.DependencyInjection.Ioc.Default.GetService <UserFollowProvider>(); flyout.UserFollowContext = FollowContext <IUser> .Create(userFollowProvider, new UserViewModel() { UserId = user.Id, Nickname = user.Nickname, IconUrl = user.Icons.Small.OriginalString }, info.Data.FollowStatus.IsFollowing); return(flyout); }
public UpdateHelper(FollowContext followContext, SourceManager sourceManager, FollowHelper followHelper, TaskTimer taskTimer) { _followContext = followContext; _sourceManager = sourceManager; _followHelper = followHelper; _taskTimer = taskTimer; }
public FollowsController(FollowContext context, IConfiguration configuration) { _context = context; _configuration = configuration; _conn = new SqlConnection(_configuration.GetConnectionString("DefaultConnection")); _comm = _conn.CreateCommand(); }
public void Setup() { var dbContext = new DbContextOptionsBuilder <FollowContext>() .UseInMemoryDatabase("KwetterFollowDatabase") .Options; _context = new FollowContext(dbContext); _createProfileHandler = new CreateProfileHandler(_context); }
public void Setup() { var mockMapper = new MapperConfiguration(cfg => { cfg.AddProfile(new AutoMapping()); }); var producer = new Mock <IProducer>(); var dbContext = new DbContextOptionsBuilder <FollowContext>() .UseInMemoryDatabase("KwetterFollowDatabase") .Options; _context = new FollowContext(dbContext); _followService = new Application.Services.FollowService(_context, mockMapper.CreateMapper(), producer.Object); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers(); ConfigureConsul(services); var secret = "eBCatxoffIIq6ESdrDZ8LKI3zpxhYkYM"; var key = Encoding.ASCII.GetBytes(secret); services.AddAuthentication(option => { option.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; option.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; }).AddJwtBearer(options => { options.RequireHttpsMetadata = false; options.SaveToken = true; options.TokenValidationParameters = new TokenValidationParameters { IssuerSigningKey = new SymmetricSecurityKey(key), ValidateIssuerSigningKey = true, ValidateIssuer = false, ValidateAudience = false }; }); services.AddAuthorization(); services.AddMessagePublishing("FollowService", builder => { builder.WithHandler <ForgetUserMessageHandler>("ForgetUserMessage"); }); var config = new ServerConfig(); Configuration.Bind(config); var followContext = new FollowContext(config.MongoDB); var repo = new FollowRepository(followContext); services.AddSingleton <IFollowRepository>(repo); services.AddScoped <IFollowService, Services.FollowService>(); }
public UsersController(UserContext userContext, PostContext postContext, FollowContext followContext) { _userContext = userContext; _postContext = postContext; _followContext = followContext; #region Creating fake users if (_userContext.Users.Count() == 0) { _userContext.Users.Add(new User { firstName = "user1", lastName = "user1", userName = "******", password = "******" }); _userContext.Users.Add(new User { firstName = "user2", lastName = "user2", userName = "******", password = "******" }); _userContext.Users.Add(new User { firstName = "user3", lastName = "user3", userName = "******", password = "******" }); _userContext.Users.Add(new User { firstName = "user4", lastName = "user4", userName = "******", password = "******" }); _userContext.SaveChanges(); } #endregion #region Creating random posts if (_postContext.PostsItems.Count() == 0) { _postContext.PostsItems.Add(new PostItem { userId = 1, userName = "", content = "post: user1" }); _postContext.PostsItems.Add(new PostItem { userId = 2, userName = "", content = "post: user2" }); _postContext.PostsItems.Add(new PostItem { userId = 3, userName = "", content = "post: user3" }); _postContext.PostsItems.Add(new PostItem { userId = 4, userName = "", content = "post: user4" }); _postContext.SaveChanges(); } #endregion #region Creating random follows if (_followContext.FollowItems.Count() == 0) { // Create a new LoginItem if collection is emdkdlslskddjfpty, // which means you can't delete all LoginItems. _followContext.FollowItems.Add(new FollowItem { followerId = 1, followingId = 2 }); _followContext.FollowItems.Add(new FollowItem { followerId = 2, followingId = 1 }); _followContext.FollowItems.Add(new FollowItem { followerId = 1, followingId = 3 }); _followContext.FollowItems.Add(new FollowItem { followerId = 1, followingId = 4 }); _followContext.SaveChanges(); } #endregion }
public FollowHelper(FollowContext context, SourceManager sourceManager) { this._context = context; this._sourceManager = sourceManager; }