Exemplo n.º 1
0
        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));
            }
        }