コード例 #1
0
        public async Task <IActionResult> PutPatient(int id, Patient patient)
        {
            if (id != patient.Id)
            {
                return(BadRequest());
            }

            _context.Entry(patient).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PatientExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #2
0
        public async Task <IActionResult> PutDoctorActivate(int id, DoctorActivate doctorActivate)
        {
            if (id != doctorActivate.Id)
            {
                return(BadRequest());
            }

            _context.Entry(doctorActivate).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DoctorActivateExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #3
0
        public async Task <ActionResult> RegisterAsDoctor([FromBody] DoctorRegisterView model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            var check_duplicated = _context.Doctor.Any(e => e.UserId == model.UserId);

            if (check_duplicated == true)
            {
                return(Conflict());
            }
            var user = await _context.AspNetUsers.FindAsync(model.UserId);

            if (user == null)
            {
                return(NotFound());
            }

            var doctor = new Doctor
            {
                UserId         = model.UserId,
                FirstName      = model.FirstName,
                LastName       = model.LastName,
                PreferName     = model.PreferName,
                ClinicAddress  = model.ClinicAddress,
                ClinicPostCode = model.ClinicPostCode,
                ClinicState    = model.ClinicState,
                ClinicSuburb   = model.ClinicSuburb,
            };

            try
            {
                // Save the Role
                // var role = _context.AspNetRoles.Where(r => r.Name == "Doctor").Single();
                var user_role = new AspNetUserRoles {
                    UserId = model.UserId, RoleId = "1"
                };
                await _context.AspNetUserRoles.AddAsync(user_role);

                doctor.User = user;
                await _context.Doctor.AddAsync(doctor);

                await _context.SaveChangesAsync();
            }
            catch (Exception e)
            {
                return(Conflict());
            }
            var result = new
            {
                Meta     = new { Status = "OK", Message = "Register as A Doctor" },
                DoctorId = doctor.Id,
                Doctor   = model
            };

            return(Ok(result));
        }
コード例 #4
0
        public async Task <ActionResult> RequestConsultSession([FromBody] RequestConsultView model)
        {
            // Save the RequestConsult First
            var requestConsult = new RequestConsult
            {
                BriefOverview  = "Overview",
                ProfessionalId = model.ProfessionalId,
                Inquiry        = model.Inquiry,
                Specification  = model.Specification,
                Urgent         = model.Urgent,
                PatientId      = model.PatientId
            };
            //await _context.RequestConsult.AddAsync(requestConsult);
            var requestConsultDocument = from document in model.RequestConsultDocument
                                         select new RequestConsultDocument
            {
                DocumentName = document.DocumentName,
                DocumentLink = document.DocumentLink,
                DocumentType = document.DocumentType
            };

            requestConsult.RequestConsultDocument = requestConsultDocument.ToList();
            await _context.RequestConsult.AddAsync(requestConsult);

            await _context.SaveChangesAsync();

            try
            {
                var result = new
                {
                    status    = "OK",
                    RequestId = requestConsult.Id
                                //Model = model
                };
                return(Ok(result));
            }catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(BadRequest());
            }
        }
コード例 #5
0
        public async Task <ActionResult> CancellationRequest(int doctorId, int requestId)
        {
            try {
                RequestCancellation requestCancellation = new RequestCancellation {
                    DoctorId = doctorId, RequestConsultId = requestId, Reason = "No Reason"
                };
                _context.RequestCancellation.Add(requestCancellation);
                await _context.SaveChangesAsync();

                var result = new
                {
                    isOk   = true,
                    docId  = doctorId,
                    reqId  = requestId,
                    reason = "No reason"
                };
                return(Ok(result));
            }catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(Conflict());
            }
        }