Пример #1
0
        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(""));
        }
Пример #2
0
 public async Task <IActionResult> AddInstructor(AddInstructorCommand command)
 {
     return(Ok(await mediator.Send(command)));
 }
Пример #3
0
        // GET: Courses/Create
        public ActionResult Create()
        {
            AddInstructorCommand instructor = new AddInstructorCommand();

            return(View(instructor));
        }
Пример #4
0
        public async Task <IActionResult> Add(AddInstructorCommand command)
        {
            int id = await Mediator.Send(command);

            return(Ok(id));
        }