public IActionResult AcceptRequest([FromBody] EmployeeRequestModelView employeeRequestModelView) { var centerId = int.Parse(Request.Cookies["CenterId"]); string component = employeeRequestModelView.Component; Request doctorRequest = doctorService.GetDoctorRequest(employeeRequestModelView.Id); try { if (employeeRequestModelView.Component == "Sange neseparat") { employeeService.AcceptBloodBag(doctorRequest, centerId, employeeRequestModelView.Rh, employeeRequestModelView.BloodType, employeeRequestModelView.QuantityNeeded); } else if (employeeRequestModelView.Component == "Trombocite") { employeeService.AcceptThrombocytes(doctorRequest, centerId, employeeRequestModelView.Rh, employeeRequestModelView.BloodType, employeeRequestModelView.QuantityNeeded); } else if (employeeRequestModelView.Component == "Plasma") { employeeService.AcceptPlasma(doctorRequest, centerId, employeeRequestModelView.BloodType, employeeRequestModelView.QuantityNeeded); } else if (employeeRequestModelView.Component == "Celule rosii") { employeeService.AcceptRedBloodCells(doctorRequest, centerId, employeeRequestModelView.Rh, employeeRequestModelView.BloodType, employeeRequestModelView.QuantityNeeded); } this.broadcaster.Clients.Group("HospitalDoctor").AcceptRequest(); return(Ok(employeeRequestModelView)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public IActionResult AddDoctorRequest([FromBody] DoctorRequestViewModel doctorRequest) { if (!ModelState.IsValid) { return(BadRequest("Can't add request")); } try { Patient patient = new Patient(); if (doctorRequest.Patient.LastName == null) { patient = patientService.GetPatientByCNP(doctorRequest.Patient.CNP); patient.Status = PatientStatus.INTERNAT; } else { Address address = Mappers.MapperPatient.ToAddressDb(doctorRequest.Patient); patient = Mappers.MapperPatient.ToPatientDb(doctorRequest.Patient); patient.Status = PatientStatus.INTERNAT; var id = Request.Cookies["UserId"]; Doctor doctor = doctorsService.GetDoctorById(id); patient.IdDoctor = doctor.Id; patientService.AddPatient(patient, address); } Request request = Mappers.MapperDoctorRequest.ToDoctorRequestDb(doctorRequest); request.IdPatient = patient.Id; request = doctorsService.AddRequest(request); doctorRequest.dateOfRequest = request.DateOfRequest; doctorRequest.id = request.Id; EmployeeRequestModelView employeeRequest = Mappers.MapperDoctorRequest.ToEmployeeRequest(request); this.broadcaster.Clients.Group("DonationCenterDoctor").SendRequest(employeeRequest); return(Ok(request)); }catch (Exception ex) { return(BadRequest("Can't add request")); } }
public static EmployeeRequestModelView ToEmployeeRequest(Request request) { var requestViewModel = new EmployeeRequestModelView() { BloodType = request.BloodType.ToString(), EmergencyLevel = request.EmergencyLevel.ToString(), Rh = request.Rh.ToString(), QuantityNeeded = request.RequestedQuantity - request.ReceivedQuantity, dateOfRequest = request.DateOfRequest, Id = request.Id }; switch (request.Component) { case ComponentType.BloodBag: requestViewModel.Component = "Sange neseparat"; break; case ComponentType.Thrombocyte: requestViewModel.Component = "Trombocite"; break; case ComponentType.Plasma: requestViewModel.Component = "Plasma"; break; case ComponentType.RedBloodCells: requestViewModel.Component = "Celule rosii"; break; default: break; } return(requestViewModel); }
public Task SendRequest(EmployeeRequestModelView request) { return(Clients.Group("DonationCenterDoctor").SendRequest(request)); }