Exemple #1
0
        public IActionResult Detail(int id)
        {
            if (!httpContextAccessor.HttpContext.User.Identity.IsAuthenticated)
            {
                return(RedirectToRoute(new
                {
                    controller = "Auth",
                    action = "Login"
                }));
            }

            var diagnoseModel = diagnose.GetById(id);

            if (diagnoseModel == null || diagnoseModel.PatientId != UserInfoHelper.GetId(httpContextAccessor))
            {
                return(NotFound());
            }

            return(View(diagnoseModel));
        }
Exemple #2
0
        public override void GetById(ObjectId id)
        {
            Collection = Connection.GetCollection(collectionName);
            var filter = Builders <BsonDocument> .Filter.Eq("_id", id);

            var document = Collection.Find(filter).First();

            _id = id;

            Description = document.GetValue("Description").AsString;

            Doctor = new Doctor();
            Doctor.GetById(document.GetValue("Doctor").AsInt32, sqlConnection);

            Article = new Article();
            Article.GetById(document.GetValue("Article").AsBsonDocument.GetValue("$id").AsObjectId, Connection);

            foreach (BsonDocument doc in document.GetValue("Tags").AsBsonArray)
            {
                Tag tag = new Tag();
                tag.GetById(doc.GetValue("$id").AsObjectId, Connection);
                Tags.Add(tag);
            }

            foreach (BsonDocument doc in document.GetValue("MedicineObjects").AsBsonArray)
            {
                switch (doc.GetValue("Table").AsString)
                {
                case "Complaint":
                    Complaint complaint = new Complaint();
                    complaint.GetById(doc.GetValue("Id").AsInt32, sqlConnection);
                    MedicineObjects.Add(complaint);
                    break;

                case "Diagnosis":
                    Diagnosis diagnosis = new Diagnosis();
                    diagnosis.GetById(doc.GetValue("Id").AsInt32, sqlConnection);
                    MedicineObjects.Add(diagnosis);
                    break;

                case "Doctor":
                    Doctor doctor = new Doctor();
                    doctor.GetById(doc.GetValue("Id").AsInt32, sqlConnection);
                    MedicineObjects.Add(doctor);
                    break;

                case "Medicament":
                    Medicament medicament = new Medicament();
                    medicament.GetById(doc.GetValue("Id").AsInt32, sqlConnection);
                    MedicineObjects.Add(medicament);
                    break;

                case "Patient":
                    Patient patient = new Patient();
                    patient.GetById(doc.GetValue("Id").AsInt32, sqlConnection);
                    MedicineObjects.Add(patient);
                    break;

                case "Problem":
                    Problem problem = new Problem();
                    problem.GetById(doc.GetValue("Id").AsInt32, sqlConnection);
                    MedicineObjects.Add(problem);
                    break;

                case "Symptom":
                    Symptom symptom = new Symptom();
                    symptom.GetById(doc.GetValue("Id").AsInt32, sqlConnection);
                    MedicineObjects.Add(symptom);
                    break;
                }
            }

            foreach (BsonDocument doc in document.GetValue("Changes").AsBsonArray)
            {
                Change change = new Change()
                {
                    ChangeTime = doc.GetValue("ChangeTime").ToUniversalTime(),
                    Content    = doc.GetValue("Content").AsString
                };
                Changes.Add(change);
            }
        }