示例#1
0
        protected async override Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            if (firstRender && !LocalDateTimeOffset.HasValue)
            {
                try
                {
                    LocalDateTimeOffset = await TimeZoneService.GetLocalDateTime(DateTimeOffset.UtcNow);
                }
                catch (Exception ex)
                {
                    _loggerCsroAuthComponentBase.LogError(ex, nameof(OnAfterRenderAsync), ex);
                }
            }
        }
示例#2
0
        protected async override Task OnInitializedAsync()
        {
            await base.OnInitializedAsync();

            CurrentUserId = await AuthCsroService.GetCurrentUserId();

            if (!LocalDateTimeOffset.HasValue)
            {
                try
                {
                    LocalDateTimeOffset = await TimeZoneService.GetLocalDateTime(DateTimeOffset.UtcNow);
                }
                catch (Exception ex)
                {
                    _loggerCsroAuthComponentBase.LogError(ex, nameof(OnInitializedAsync), ex);
                }
            }
        }
示例#3
0
        public IActionResult Edit(Guid id)
        {
            Post post;

            if (id == default)
            {
                post = new Post();
            }
            else
            {
                post = _postService.Get(id);
                if (post == null)
                {
                    return(NotFound());
                }
            }
            post.PostedDate    = _timeZoneService.GetLocalDateTime(post.PostedDate);
            ViewBag.Categories = new SelectList(_postCategoryService.GetAll(), "Id", "Name");
            return(View(post));
        }