Esempio n. 1
0
        private async Task EditDiary()
        {
            if (!IsAuthenticated)
            {
                return;
            }

            if (DiaryInfo == null)
            {
                return;
            }

            List <DiaryContent> content;

            if (DiaryInfo.IsSecret)
            {
                content = await DiaryService.UpdateDiaryAsync(User, DiaryInfo, View.DiaryContents, UserData.Password);
            }
            else
            {
                content = await DiaryService.UpdateDiaryAsync(User, DiaryInfo, View.DiaryContents);
            }

            if (content?.Any() ?? false)
            {
                Navi.NavigateTo(DiaryUrl.DiaryContent(DiaryInfo.DiaryName, content.First().Date));
            }
            else
            {
                Navi.NavigateTo(DiaryUrl.Home(DiaryInfo.DiaryName));
            }
        }
Esempio n. 2
0
        async Task WriteDiaryAsync()
        {
            if (!IsAuthenticated)
            {
                return;
            }

            if (DiaryInfo == null)
            {
                return;
            }

            DiaryContent content;

            if (DiaryInfo.IsSecret)
            {
                content = await DiaryService.WriteDiaryAsync(User, DiaryInfo, Date, Content, UserData.Password);
            }
            else
            {
                content = await DiaryService.WriteDiaryAsync(User, DiaryInfo, Date, Content);
            }

            if (content != null)
            {
                Navi.NavigateTo(DiaryUrl.DiaryContent(DiaryInfo.DiaryName, Date));
            }
        }
Esempio n. 3
0
        protected override async Task OnPageInitializedAsync()
        {
            if (!IsAuthenticated)
            {
                Navi.NavigateTo("/login");
                return;
            }

            var list = await DiaryService.GetWritableDiaryInfoAsync(User);

            DiaryInfo = list.FirstOrDefault(x => x.DiaryName == DiaryName);

            if (DiaryInfo == null)
            {
                Navi.NavigateTo(DiaryUrl.Home(DiaryName));
            }

            if (DiaryInfo.IsSecret && string.IsNullOrWhiteSpace(UserData.Password))
            {
                Navi.NavigateTo(DiaryUrl.SetPassword());
                return;
            }

            LastDiary = await DiaryService.GetLastDiaryViewAsync(User, DiaryInfo);

            Date = DateTime.Today;
        }
        private async Task CreateDiaryAsync(DiaryCreateModel model)
        {
            try
            {
                var diary = await DiaryService.CreateDiaryInfoAsync(User, model.DiaryName, model.IsSecret);

                Navi.NavigateTo(DiaryUrl.Home(diary.DiaryName));
            }
            catch
            {
            }
        }
Esempio n. 5
0
        private async Task InitDiary()
        {
            DiaryInfo = null;
            View      = null;

            if (!string.IsNullOrWhiteSpace(DiaryName))
            {
                DiaryInfo = await DiaryService.GetDiaryInfoAsync(User, DiaryName);
            }
            else
            {
                var userDiaryInfo = await DiaryService.GetUserDiaryInfoAsync(User);

                if (userDiaryInfo.MyDiaryList.Empty())
                {
                    return;
                }

                var diaryName = userDiaryInfo.MyDiaryList.First();
                DiaryInfo = await DiaryService.GetDiaryInfoAsync(User, diaryName);
            }

            if (DiaryInfo == null)
            {
                return;
            }

            if (DiaryInfo.IsSecret && string.IsNullOrWhiteSpace(UserData.Password))
            {
                Navi.NavigateTo(DiaryUrl.SetPassword());
                return;
            }
            //WritableDiary = await DiaryService.GetWritableDiaryInfoAsync(User);
            //ViewableDiary = await DiaryService.GetViewableDiaryInfoAsync(User);

            if (HasDiaryInfo)
            {
                if (string.IsNullOrWhiteSpace(Date))
                {
                    View = await DiaryService.GetLastDiaryViewAsync(User, DiaryInfo);
                }
                else if (Date.TryToDate(out var parsedDate))
                {
                    View = await DiaryService.GetDiaryViewAsync(User, DiaryInfo, parsedDate);
                }

                if (DiaryInfo.IsSecret && HasDiaryContent)
                {
                    foreach (var content in View?.DiaryContents)
                    {
                        try
                        {
                            content.Text = content.Text.Decrypt(UserData.Password);
                        }
                        catch
                        {
                            content.Text = "임호화된 일기를 해석하지 못했습니다. 비밀번호를 다시 확인해주세요.";
                        }
                    }
                }
            }
        }
Esempio n. 6
0
        private async Task InitDiary()
        {
            Logger?.LogDebug("InitDiary");

            DiaryInfo = null;
            View      = null;

            if (!IsAuthenticated)
            {
                Logger?.LogDebug("Not Authenticated");
                return;
            }

            if (!string.IsNullOrWhiteSpace(DiaryName))
            {
                DiaryInfo = await GetDiaryInfo(DiaryName);

                MyDiaryInfo = await GetMyDiaryInfo();
            }
            else
            {
                DiaryInfo = MyDiaryInfo = await GetMyDiaryInfo();
            }

            if (DiaryInfo == null)
            {
                Logger?.LogDebug("DiaryInfo is null");
                return;
            }

            Logger?.LogDebug("Set DiaryInfo: {diaryInfo}", Json.Serialize(DiaryInfo));

            if (DiaryInfo.IsSecret && string.IsNullOrWhiteSpace(UserData.Password))
            {
                Navi.NavigateTo(DiaryUrl.SetPassword());
                return;
            }
            //WritableDiary = await DiaryService.GetWritableDiaryInfoAsync(User);
            //ViewableDiary = await DiaryService.GetViewableDiaryInfoAsync(User);

            if (HasDiaryInfo)
            {
                if (string.IsNullOrWhiteSpace(Date))
                {
                    View = await DiaryService.GetLastDiaryViewAsync(User, DiaryInfo);
                }
                else if (Date.TryToDate(out var parsedDate))
                {
                    View = await DiaryService.GetDiaryViewAsync(User, DiaryInfo, parsedDate);
                }

                if (DiaryInfo.IsSecret && HasDiaryContent)
                {
                    foreach (var content in View?.DiaryContents)
                    {
                        try
                        {
                            content.Text = content.Text.Decrypt(UserData.Password);
                        }
                        catch
                        {
                            content.Text = "임호화된 일기를 해석하지 못했습니다. 비밀번호를 다시 확인해주세요.";
                        }
                    }
                }
            }
        }