public IActionResult OnPost() { if (ModelState.IsValid) { var dbAd = _adsService.GetAdById(Ad.Id); if (dbAd == null) // create new { //get current user var identityClaim = _httpContext.HttpContext.User; var user = _userService.GetUserAsync(identityClaim).Result; Ad.Owner = user; var success = _adsService.CreateAdAsync(Ad); return(Redirect("MyAds")); //todo: add success message } else // update { _adsService.UpdateAdd(Ad); //todo: add success message return(Redirect("Index")); } } return(Page()); }