コード例 #1
0
        public CommunicationNeedViewModel GetCommunicationNeed(int PatientId, string UserId, bool isPharmixAdmin)
        {
            var result  = new CommunicationNeedViewModel();
            var IsAdmin = false;

            if (IsAdminUser(UserId, isPharmixAdmin))
            {
                IsAdmin = true;
            }
            else
            {
                PatientId = _repository.GetContext().Patients.Where(p => p.UserId == UserId).Select(p => p.Id).FirstOrDefault();
            }

            var communicationNeed = _repository.GetContext().CommunicationNeed.Include(p => p.Pregnancy).Where(p => p.Pregnancy.PatientId == PatientId).FirstOrDefault();

            if (communicationNeed == null)
            {
                result = new CommunicationNeedViewModel();
            }
            else
            {
                result = Mapper.Map <CommunicationNeed, CommunicationNeedViewModel>(communicationNeed);
            }

            result.IsAdmin   = IsAdmin;
            result.PatientId = PatientId;
            return(result);
        }
コード例 #2
0
        public bool SaveCommunicationNeed(CommunicationNeedViewModel model, string UserId)
        {
            var result = false;

            try
            {
                var pregnancy = _repository.GetContext().Pregnancy.Where(p => p.PatientId == model.PatientId).FirstOrDefault();
                if (model.Id > 0)
                {
                    //Update Existing
                    var communicationNeed = _repository.GetContext().CommunicationNeed.Where(p => p.Id == model.Id).FirstOrDefault();
                    communicationNeed.AssistanceRequired       = model.AssistanceRequired;
                    communicationNeed.AssistanceRequiredDetail = model.AssistanceRequiredDetail;
                    communicationNeed.PreferredAssistance      = model.PreferredAssistance;
                    communicationNeed.SpeakEnglish             = model.SpeakEnglish;
                    communicationNeed.FirstLanguage            = model.FirstLanguage;
                    communicationNeed.PreferedLanguage         = model.PreferedLanguage;
                    communicationNeed.InterpreterPhone         = model.InterpreterPhone;
                    communicationNeed.SetUpdateDetails(UserId);

                    _repository.SaveExisting(communicationNeed);
                }
                else
                {
                    //Add new Record
                    var communicationNeed = new CommunicationNeed();
                    communicationNeed.AssistanceRequired       = model.AssistanceRequired;
                    communicationNeed.AssistanceRequiredDetail = model.AssistanceRequiredDetail;
                    communicationNeed.PreferredAssistance      = model.PreferredAssistance;
                    communicationNeed.SpeakEnglish             = model.SpeakEnglish;
                    communicationNeed.FirstLanguage            = model.FirstLanguage;
                    communicationNeed.PreferedLanguage         = model.PreferedLanguage;
                    communicationNeed.InterpreterPhone         = model.InterpreterPhone;
                    communicationNeed.PregnancyId = pregnancy.Id;
                    communicationNeed.SetCreateDetails(UserId);

                    var saveNew = _repository.SaveNew(communicationNeed);
                }

                result = true;
            }
            catch (Exception ex)
            {
                result = false;
            }

            return(result);
        }