public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { await FetchData().ConfigureAwait(false); return(this.TurboPage()); } if (!await FetchData().ConfigureAwait(false)) { return(RedirectToPage("/Index")); } return((await companies.CreateProductType(new ProductType { ProductTypeName = Input.ProductTypeName }) .Ensure(c => c.HasValue, "Product Type was created") .OnSuccess(c => this.RedirectToPage("/ProductType", new { producttypeId = c.Value })) .OnFailure(() => this.Page()) .ConfigureAwait(false)).Value); }