public ActionResult Create(PatientViewModel vm, string patientId = "") { try { _patientService.Add(Mapper.Map <Patient>(vm)); return(JavaScript("ShowResult('Data saved successfully.','success')")); } catch (Exception ex) { throw new Exception(ex.Message); } }
public HttpResponseMessage addupFromApp(HttpRequestMessage request) { HttpContent requestContent = Request.Content; string jsonContent = requestContent.ReadAsStringAsync().Result; PhieuSangLocViewModel phieuSangLocVm = JsonConvert.DeserializeObject <PhieuSangLocViewModel>(jsonContent); var userName = HttpContext.Current.GetOwinContext().Authentication.User.Identity.Name; var user = userManager.FindByNameAsync(userName).Result; if (phieuSangLocVm.MaTrungTam != user.LevelCode && !phieuSangLocVm.IDPhieu.Contains(user.LevelCode)) { return(request.CreateResponse(HttpStatusCode.ExpectationFailed, "Phiếu " + phieuSangLocVm.IDPhieu + "không thuộc trung tâm " + user.LevelCode)); } HttpResponseMessage response = null; var phieuDB = phieuSangLocService.GetById(phieuSangLocVm.IDPhieu); if (phieuDB == null) { var newPhieu = new PhieuSangLoc(); newPhieu.UpdatePhieuSangLoc(phieuSangLocVm); var lvcode = user.LevelCode; newPhieu.IDNhanVienTaoPhieu = user.Id; var newPatient = new Patient(); newPatient.UpdatePatient(phieuSangLocVm); newPhieu.MaBenhNhan = lvcode[1] + lvcode[2] + Guid.NewGuid().ToString(); newPatient.MaBenhNhan = newPhieu.MaBenhNhan; phieuSangLocService.Add(newPhieu); patientService.Add(newPatient); phieuSangLocService.Save(); response = request.CreateResponse(HttpStatusCode.Created, phieuSangLocVm); } else { phieuDB.UpdatePhieuSangLoc(phieuSangLocVm); var patientDB = patientService.GetByMaBN(phieuSangLocVm.MaBenhNhan); patientDB.UpdatePatient(phieuSangLocVm); this.phieuSangLocService.Update(phieuDB); this.patientService.Update(patientDB); donViCoSoService.Save(); response = request.CreateResponse(HttpStatusCode.OK); } return(response); }
public async Task <OkObjectResult> Post([FromBody] Patient patient) { var Patient = new Patient() { Name = patient.Name, Surname = patient.Surname, UserId = patient.UserId, Gender = patient.Gender, telNumber = patient.telNumber, birthdayDate = patient.birthdayDate, Adress = patient.Adress, PESEL = patient.PESEL }; try { var result = await _patientService.Add(Patient); return(Ok(result)); } catch (Exception ex) { throw ex; } }
public async Task <IActionResult> CreatePetient(int doctorId, PatientForCreateDto patientForCreateDto) { if (doctorId != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value)) { return(Unauthorized("Пользователь не авторизован")); } patientForCreateDto.PersonalCardNumber = patientForCreateDto.PersonalCardNumber.Trim(); if (await _patientService.PatientIsExistAsync(patientForCreateDto.PersonalCardNumber)) { return(BadRequest("В системе уже существует пациент с указым номером карточки.")); } var patient = _mapper.Map <Patient>(patientForCreateDto); _patientService.Add(patient); if (await _patientService.SaveAllAsync()) { return(Ok(patient)); } throw new Exception("Не предвиденая ошибка в ходе добавления пациента, обратитесь к администратору."); }
public IActionResult Add(Patient patient) { if (_patientService.Add(patient) == null) { return(NotFound()); } return(Ok(PatientAdapter.PatientToPatientDto(patient))); }
public async Task <IActionResult> CreatePatient(PatientDTO patientDTO) { if (ModelState.IsValid) { await _patientService.Add(patientDTO); } return(Ok($"Paciente {patientDTO.Name} cadastrado.")); }
public IActionResult Add(Patient patient) { var result = _patientService.Add(patient); if (result.Success) { return(Ok(result.Message)); } return(BadRequest(result.Message)); }
public async Task <IActionResult> Add([FromBody] PatientRequest request) { var outputHandler = await _service.Add(request); if (outputHandler.IsErrorOccured) { return(BadRequest(outputHandler.Message)); } return(Created("", outputHandler.Message)); }
public IActionResult Index([FromBody] PatientCreationModel newPatient) { if (ModelState.IsValid) { var patientInfo = patientService.Add(newPatient); return(Ok(patientInfo)); } return(BadRequest(ModelState)); }
public async Task <Object> Put(string token, [FromBody] Location location) { //var stream = "[encoded jwt]"; var handler = new JwtSecurityTokenHandler(); var jsonToken = handler.ReadToken(token); var tokenS = handler.ReadToken(token) as JwtSecurityToken; var jti = tokenS.Claims.First(claim => claim.Type == "role").Value; return(await PatientService.Add(Int32.Parse(jti), location)); }
public ActionResult Create(Patient patient) { if (patient != null) { if (!string.IsNullOrEmpty(patient.patientName) || !string.IsNullOrWhiteSpace(patient.patientName)) { _patientService.Add(patient); _logger.LogInformation("New patient was added!"); } } return(RedirectToAction(nameof(Index))); }
public async Task Add(PatientViewModel patientViewModel) { try { // local time zone offset as TimeSpan object // add the offsetTime to the datetime recieved as UTC var patient = _mapper.Map <PatientViewModel, Patient>(patientViewModel); await _patientService.Add(patient); } catch (Exception exp) { Console.WriteLine(exp); } }
public CommonResponse Add(PatientViewModel patientViewModel) { CommonResponse <PatientViewModel> response = new CommonResponse <PatientViewModel>(); try { var model = _patientService.Add(_mapper.Map <Patient>(patientViewModel)); response.Result = _mapper.Map <PatientViewModel>(model); } catch (ServiceException ex) { response.StatusText = ex.Message; } return(response); }
public void Post([FromBody] PatientViewModel model) { if (ModelState.IsValid) { patientService.Add(new WebApp.Services.Models.Patient() { Address = model.Address, Email = model.Email, Gender = model.Gender, Name = model.Name, PatientNbr = model.PatientNbr, PhoneNbr = model.PhoneNbr }); } }
public IActionResult Index(PatientViewModel model) { if (ModelState.IsValid) { patientService.Add(new Patient() { Address = model.Address, Email = model.Email, Name = model.Name, PatientNbr = model.PatientNbr, PhoneNbr = model.PhoneNbr, Gender = model.Gender }); } return(View(model)); }
private void AddPatient() { Console.Clear(); Console.WriteLine("First Name:"); var firtsName = Console.ReadLine(); Console.WriteLine("Last Name:"); var lastName = Console.ReadLine(); Console.WriteLine("Age:"); var answer = Console.ReadLine(); int age; var result = Int32.TryParse(answer, out age); if (result) { Console.WriteLine("Doctor:"); answer = Console.ReadLine(); int id; result = Int32.TryParse(answer, out id); if (result) { var patientId = patients.GetMaxId() + 1; patients.Add(new Patient() { FirstName = firtsName, LastName = lastName, Id = patientId, Age = age, DoctorId = id }); } else { Console.WriteLine("Incorrect input of doctor's identificator!"); } } else { Console.WriteLine("Incorrect input of age!"); } }
public HttpResponseMessage Create(HttpRequestMessage request, PhieuSangLocViewModel phieuSangLocVm) { return(CreateHttpResponse(request, () => { HttpResponseMessage response = null; if (!ModelState.IsValid) { response = request.CreateResponse(HttpStatusCode.BadRequest, ModelState); } else { var phieuDB = phieuSangLocService.GetById(phieuSangLocVm.IDPhieu); if (phieuDB != null) { phieuDB.UpdatePhieuSangLoc(phieuSangLocVm); var patientDB = patientService.GetByMaBN(phieuSangLocVm.MaBenhNhan); patientDB.UpdatePatient(phieuSangLocVm); this.phieuSangLocService.Update(phieuDB); this.patientService.Update(patientDB); donViCoSoService.Save(); response = request.CreateResponse(HttpStatusCode.OK); } else { var newPhieu = new PhieuSangLoc(); newPhieu.UpdatePhieuSangLoc(phieuSangLocVm); ApplicationUser user = this.userManager.FindByNameAsync(phieuSangLocVm.Username).Result; newPhieu.IDNhanVienTaoPhieu = user.Id; var newPatient = new Patient(); newPatient.UpdatePatient(phieuSangLocVm); newPhieu.MaBenhNhan = Guid.NewGuid().ToString(); newPatient.MaBenhNhan = newPhieu.MaBenhNhan; phieuSangLocService.Add(newPhieu); patientService.Add(newPatient); phieuSangLocService.Save(); response = request.CreateResponse(HttpStatusCode.Created, phieuSangLocVm); } } return response; })); }
public async Task Add(PatientDto patientDto) { try { if (patientDto.FirstName == "Test") { throw new Exception("Name can not be Test"); } // local time zone offset as TimeSpan object // add the offsetTime to the datetime recieved as UTC var patient = _mapper.Map <PatientDto, Patient>(patientDto); await _patientService.Add(patient); } catch (Exception exp) { Console.WriteLine(exp); throw; } }
public ActionResult Create(FormCollection collection) { try { bool gender = collection["Gender"] == "Male"; int heightFt = Int32.Parse(collection["heigthFt"]); int heightIn = Int32.Parse(collection["heightIn"]); int age = Int32.Parse(collection["years"]); patientService.Add(new Patient() { Gender = gender, HeightFt = heightFt, HeightIn = heightIn, Age = age }); return(RedirectToAction("Index")); } catch { return(View()); } }
public IHttpActionResult Post(PatientDto patientDto) { patientService.Add(patientDto); return(Created("", patientDto)); }
public async Task AddPatient([FromBody] PatientDTO patientDTO) { await _patientService.Add(patientDTO); }
public IActionResult Add(GuestPatientDTO guestPatient) { _service.Add(guestPatient); return(NoContent()); }
public JsonResult Post([FromBody] ContractRequest <AddUpdatePatientRequest> request) { var patientsResponse = _patientService.Add(request); return(Json(patientsResponse)); }
public ContentResult CreatePatient(Patient patient) { patientService.Add(patient); patientService.Save(); return(Content("<p>The patient was created successfully!</p>")); }