public void CreatePatient() { Console.WriteLine("Введите фамилию"); var surname = Console.ReadLine(); Console.WriteLine("Введите имя"); var name = Console.ReadLine(); Console.WriteLine("Введите отчество"); var middleName = Console.ReadLine(); var patient = new Patient { Surname = surname, Name = name, MiddleName = middleName, }; var creationProcess = _patientService.AddAsync(patient); Task.WaitAll(creationProcess); Console.WriteLine("Пациент добавлен успешно"); Console.ReadKey(); }
public async Task <IActionResult> Post(PatientDto patientDTO) { var userId = User.Claims.First(c => c.Type == ClaimTypes.NameIdentifier).Value; if (userId == null) { return(BadRequest()); } var patient = await _patientService.AddAsync(patientDTO, userId); return(CreatedAtAction(nameof(Get), new { name = patient.Name })); }
public async Task <IHttpActionResult> PostPatient(PatientDto patientDto) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Patient patient = new Patient(); Mapper.Map(patientDto, patient); patient = await _patientService.AddAsync(patient); patientDto.Id = patient.Id; return(CreatedAtRoute("ApiRoute", new { id = patientDto.Id }, patientDto)); }
public async Task <ActionResult> CreatePatient(Patient patient) { if (!ModelState.IsValid) { ViewBag.patient = "Not Valid"; } try { await _patientService.AddAsync(patient); } catch (Exception e) { Console.WriteLine(e); throw; } return(RedirectToAction("Index")); }