Ejemplo n.º 1
0
        private async Task Send()
        {
            var userNameTask = LocalStorageService.GetStringAsync(LocalStorageAttributes.UserNameKeyName);
            var userImgTask  = LocalStorageService.GetStringAsync(LocalStorageAttributes.UserImgKeyName);
            var userIdTask   = LocalStorageService.GetStringAsync(LocalStorageAttributes.UserIdKeyName);

            await Task.WhenAll(userNameTask, userIdTask, userImgTask);

            var user = new ShortUserInfoContract
            {
                UserId   = userIdTask.Result,
                UserName = userNameTask.Result,
                UserImg  = userImgTask.Result,
            };

            var message = new CreateMessageContract
            {
                Content = messageInput,
                User    = user,
            };

            await Http.PostAsync($"api/messages/{ChatId}", message);

            messageInput = string.Empty;
        }
Ejemplo n.º 2
0
        protected override async Task OnInitializedAsync()
        {
            string localStorageId = await LocalStorageService.GetStringAsync(LocalStorageAttributes.UserIdKeyName);

            if (string.IsNullOrEmpty(localStorageId))
            {
                await LocalStorageService.SetStringAsync(LocalStorageAttributes.UserIdKeyName, Guid.NewGuid().ToString());
            }

            string localStorageName = await LocalStorageService.GetStringAsync(LocalStorageAttributes.UserNameKeyName);

            UserName = string.IsNullOrWhiteSpace(localStorageName) ? "anon" : localStorageName;
            UserImg  = await LocalStorageService.GetStringAsync(LocalStorageAttributes.UserImgKeyName);

            await base.OnInitializedAsync();
        }
Ejemplo n.º 3
0
 protected override async Task OnInitializedAsync()
 {
     userId = await LocalStorageService.GetStringAsync(LocalStorageAttributes.UserIdKeyName);
 }