public async Task <ActionResult> Create(AddInstructorCommand addInstructorCommand) { var ok = false; using (var httpClient = new HttpClient()) { string json = JsonConvert.SerializeObject(addInstructorCommand); HttpContent content = new StringContent(json, System.Text.Encoding.UTF8, "application/json"); Console.WriteLine("json " + json); using var response = await httpClient.PostAsync(_configuration.GetSection ("apiUrl").Value + "/instructors/Add", content); Console.WriteLine(await response.Content.ReadAsStringAsync()); if (response.StatusCode == HttpStatusCode.OK) { ok = true; } } return(RedirectToAction("")); }
public async Task <IActionResult> AddInstructor(AddInstructorCommand command) { return(Ok(await mediator.Send(command))); }
// GET: Courses/Create public ActionResult Create() { AddInstructorCommand instructor = new AddInstructorCommand(); return(View(instructor)); }
public async Task <IActionResult> Add(AddInstructorCommand command) { int id = await Mediator.Send(command); return(Ok(id)); }