public IActionResult GetFeedbacksNotReaded()
        {
            try
            {
                var Feedback = _feedbackData.GetFeedbackByNotReaded();

                if (Feedback.Count > 0)
                {
                    return(Ok(Feedback));
                }

                return(NotFound());
            }
            catch (Exception ex)
            {
                _apiErrorHandler.CreateError(ex.Source, ex.StackTrace, ex.Message);
            }

            return(StatusCode(500));
        }
        public IActionResult GetPlans()
        {
            try
            {
                List <PlanModel> Plan = _planData.GetPlans();

                if (Plan.Count > 0)
                {
                    return(Ok(Plan));
                }

                return(NotFound());
            }
            catch (Exception ex)
            {
                _apiErrorHandler.CreateError(ex.Source, ex.StackTrace, ex.Message);
            }

            return(StatusCode(500));
        }
Exemple #3
0
        public IActionResult GetRoles()
        {
            try
            {
                var roles = _roleData.FindRoles <ApplicationRole>();

                if (roles != null)
                {
                    return(Ok(roles));
                }

                return(NotFound());
            }
            catch (Exception ex)
            {
                _apiErrorHandler.CreateError(ex.Source, ex.StackTrace, ex.Message);
            }

            return(StatusCode(500));
        }
Exemple #4
0
        public IActionResult GetMedicines()
        {
            try
            {
                var Medicines = _medicineData.GetMedicines();

                if (Medicines.Count > 0)
                {
                    return(Ok(Medicines));
                }

                return(NotFound());
            }
            catch (Exception ex)
            {
                _apiErrorHandler.CreateError(ex.Source, ex.StackTrace, ex.Message);
            }

            return(StatusCode(500));
        }
        public IActionResult GetByPatientID(string patientID)
        {
            try
            {
                List <PatientProgressModel> Progresses = _patientProgressData.GetPatientProgressesByPatientId(patientID);

                if (Progresses.Count > 0)
                {
                    return(Ok(Progresses));
                }

                return(NotFound());
            }
            catch (Exception ex)
            {
                _apiErrorHandler.CreateError(ex.Source, ex.StackTrace, ex.Message);
            }

            return(StatusCode(500));
        }
Exemple #6
0
        public IActionResult GetTests()
        {
            try
            {
                var Tests = _labTest.GetTests();

                if (Tests.Count > 0)
                {
                    return(Ok(Tests));
                }

                return(NotFound());
            }
            catch (Exception ex)
            {
                _apiErrorHandler.CreateError(ex.Source, ex.StackTrace, ex.Message);
            }

            return(StatusCode(500));
        }
Exemple #7
0
        public IActionResult GetAssignedMed()
        {
            string UserId = User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
            List <AssignedMedicineModel> assignedMedicines;
            string RoleType = ClaimTypes.Role.ToString();

            try
            {
                if (User.HasClaim(RoleType, "Patient"))
                {
                    assignedMedicines = _assignedMedicine.GetAssignedPatientId(UserId);

                    var model = _mapper.Map <PatientAssignedMedicineDisplayModel>(assignedMedicines);

                    if (assignedMedicines.Count > 0)
                    {
                        return(Ok(model));
                    }

                    return(NotFound());
                }

                if (User.HasClaim(RoleType, "Doctor"))
                {
                    assignedMedicines = _assignedMedicine.GetAssignedDoctorId(UserId);

                    if (assignedMedicines.Count > 0)
                    {
                        Ok(assignedMedicines);
                    }
                    return(NotFound());
                }
            }
            catch (Exception ex)
            {
                _apiErrorHandler.CreateError(ex.Source, ex.StackTrace, ex.Message);
            }

            return(StatusCode(500));
        }
        public IActionResult GetPublicArticles()
        {
            try
            {
                List <ArticleModel> Result = _articleData.FindArticles(true);

                if (Result.Count > 0)
                {
                    var model = _mapper.Map <List <PublicArticleDisplayModel> >(Result);

                    return(Ok(model));
                }

                return(NotFound("There is no Articels"));
            }
            catch (Exception ex)
            {
                _apiErrorHandler.CreateError(ex.Source, ex.StackTrace, ex.Message);
            }

            return(StatusCode(500));
        }
        public IActionResult GetNotesForDoctor(string patientId)
        {
            try
            {
                string DoctorId = User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
                List <PatientNoteModel> Notes = _patientNoteData.GetNotesByPatientAndDoctorId(patientId, DoctorId);

                var model = _mapper.Map <DoctorPatientNoteDisplayModel>(Notes);

                if (Notes.Count > 0)
                {
                    return(Ok(model));
                }
                return(NotFound());
            }
            catch (Exception ex)
            {
                _apiErrorHandler.CreateError(ex.Source, ex.StackTrace, ex.Message);
            }

            return(StatusCode(500));
        }
Exemple #10
0
        // return only plan that has patient ID
        public IActionResult GetAssignedPlans()
        {
            string UserId = User.FindFirst(ClaimTypes.NameIdentifier)?.Value;

            try
            {
                var AssignedPlans = _assignedPlanData.GetAssignedPlansByPaitnetID(UserId);
                var model         = _mapper.Map <PatientAssignedPlanDisplayModel>(AssignedPlans);

                if (AssignedPlans.Count > 0)
                {
                    return(Ok(model));
                }

                return(NotFound("No plans to show"));
            }
            catch (Exception ex)
            {
                _apiErrorHandler.CreateError(ex.Source, ex.StackTrace, ex.Message);
            }

            return(StatusCode(500));
        }
Exemple #11
0
        public IActionResult GetPatientByID(string id)
        {
            try
            {
                var Patient = _patientData.GetPatientByID(id);

                return(Ok(Patient));
            }
            catch (Exception ex)
            {
                _apiErrorHandler.CreateError(ex.Source, ex.StackTrace, ex.Message);
            }

            return(StatusCode(500));
        }
Exemple #12
0
        public IActionResult GetArticles()
        {
            try
            {
                string UserId = User.FindFirst(ClaimTypes.NameIdentifier)?.Value;

                List <ArticleModel> articles = _articleData.FindArticlesByUserId(UserId);

                var model = _mapper.Map <List <PrivateArticelDisplayModel> >(articles);

                if (articles.Count > 0)
                {
                    return(Ok(model));
                }

                return(NotFound("No Articels found"));
            }
            catch (Exception ex)
            {
                _apiErrorHandler.CreateError(ex.Source, ex.StackTrace, ex.Message);
            }

            return(StatusCode(500));
        }
        public async Task <IActionResult> Create(string username, string password)
        {
            try
            {
                if (await IsValidUsernameAndPassword(username, password))
                {
                    return(new ObjectResult(await GenerateToken(username)));
                }
                else
                {
                    return(BadRequest("User Name or Password wrong"));
                }
            }
            catch (Exception ex)
            {
                _apiErrorHandler.CreateError(ex.Source, ex.StackTrace, ex.Message);
            }

            return(StatusCode(500));
        }
        public IActionResult UpdateUser([FromBody] AccountViewModel userInput)
        {
            try
            {
                //TODO before update, check if the user update his information only
                //TODO Cheeck if he is in the database before

                string UserId = User.FindFirst(ClaimTypes.NameIdentifier)?.Value;

                var model = _mapper.Map <UserModel>(userInput);
                model.Id = UserId;

                _userData.UpdateUser(model);

                return(Ok($"{UserId} information Updated "));
            }
            catch (Exception ex)
            {
                _apiErrorHandler.CreateError(ex.Source, ex.StackTrace, ex.Message);
            }

            return(StatusCode(500));
        }
Exemple #15
0
        public IActionResult GetArticles()
        {
            try
            {
                List <ArticleModel> articles = _articleData.FindArticles();

                if (articles.Count > 0)
                {
                    return(Ok(articles));
                }
                else
                {
                    return(NotFound("There is no Articles to show"));
                }
            }
            catch (Exception ex)
            {
                _apiErrorHandler.CreateError(ex.Source, ex.StackTrace, ex.Message);
            }
            return(StatusCode(500));
        }