public AccountModule(ICommandDispatcher commandDispatcher, IValidatorResolver validatorResolver, IUserStorage userStorage, INotificationSettingsStorage notificationSettingsStorage) : base(commandDispatcher, validatorResolver) { Get("account", async args => await Fetch <GetAccount, User> (async x => await userStorage.GetAsync(x.UserId)).HandleAsync()); Get("account/settings/notifications", async args => await Fetch <GetNotificationSettings, UserNotificationSettings> (async x => await notificationSettingsStorage.GetAsync(x.UserId)) .HandleAsync()); Get("account/names/{name}/available", async args => await Fetch <GetNameAvailability, AvailableResource> (async x => await userStorage.IsNameAvailableAsync(x.Name)).HandleAsync()); Put("account/name", async args => await For <ChangeUsername>() .OnSuccessAccepted("account") .DispatchAsync()); Put("account/settings/notifications", async args => await For <UpdateUserNotificationSettings>() .OnSuccessAccepted("account") .DispatchAsync()); Post("sign-up", async(ctx, p) => await For <SignUp>() .Set(x => { x.Role = string.Empty; x.State = string.Empty; }) .OnSuccessAccepted("account") .DispatchAsync()); Post("account/avatar", async args => await For <UploadAvatar>() .OnSuccessAccepted("account") .DispatchAsync()); Post("account/activate", async args => await For <ActivateAccount>() .OnSuccessAccepted("account") .DispatchAsync()); Delete("account/avatar", async args => await For <RemoveAvatar>() .OnSuccessAccepted() .DispatchAsync()); Put("account/password", async args => await For <ChangePassword>() .OnSuccessAccepted("account") .DispatchAsync()); Delete("account", async args => await For <DeleteAccount>() .OnSuccessAccepted() .DispatchAsync()); }
public async Task <ActionResult <GetUserResponse> > GetAsync([FromRoute] long userId) { if (!User.HasClaim(AuthConsts.Claims.Types.UserId, userId.ToString())) { logger.LogInformation($"You have no access to {userId}"); return(StatusCode(403, $"You have no access to {userId}")); } var user = await userStorage.GetAsync(userId).ConfigureAwait(false); if (user == null) { return(NotFound()); } return(Ok(user.ToGetUserResponse())); }
public void CreateDeed() { var rand = new Random(); var userFirst = AsyncExecutionHelper.RunSync(async() => await _userStorage.GetAsync(null)); AsyncExecutionHelper.RunSync(async() => await _deedStorage.CreateAsync(new Deed { Name = "Test sasaasasas", DescriptionPublic = "Public description", DescriptionPrivate = "Private description", UserId = userFirst.UserId, //User = userFirst Latitude = rand.Next(10, 100), Longitude = rand.Next(10, 100), })); Assert.AreEqual(true, true); }
public AccountModule(ICommandDispatcher commandDispatcher, IValidatorResolver validatorResolver, IIdentityProvider identityProvider, IUserStorage userStorage) : base(commandDispatcher, validatorResolver, identityProvider) { Get("account", async args => await Fetch <GetAccount, User> (async x => await userStorage.GetAsync(x.UserId)).HandleAsync()); Get("usernames/{name}/available", async args => await Fetch <GetNameAvailability, AvailableResource> (async x => await userStorage.IsNameAvailableAsync(x.Name)).HandleAsync()); Put("account/name", async args => await For <ChangeUsername>() .OnSuccessAccepted("account") .DispatchAsync()); Put("account/avatar", async args => await For <ChangeAvatar>() .OnSuccessAccepted("account") .DispatchAsync()); Put("account/password", async args => await For <ChangePassword>() .OnSuccessAccepted("account") .DispatchAsync()); }