Пример #1
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!sessionHelper.IsLoggedIn)
            {
                return(RedirectToPage("./Login"));
            }

            if (!ModelState.IsValid)
            {
                return(Page());
            }

            try
            {
                var customer = customerFactory.BuildForEdit(FormData, sessionHelper.UserId);

                var client = clientFactory.CreateClient("MarinaApi");
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", sessionHelper.AccessToken);
                await client.PutAsJsonAsync("Customer", customer);

                return(RedirectToPage("./Account"));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }