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); } } }
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); } } }
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)); }