public ProcessResult Delete(int id)
        {
            ProcessResult result = new ProcessResult();

            RendezvousManager  rendezvousManager  = new RendezvousManager();
            Rendezvous         rendezvous         = rendezvousManager.Select(id);
            ExaminationManager examinationManager = new ExaminationManager();

            foreach (Examination examination in
                     examinationManager.Examinations(rendezvous.Date, rendezvous.DoctorId, null).Where(e => e.RendezvousId == id).ToList())
            {
                examinationManager.Delete(examination.Id);
            }

            switch (_rendezvousDal.Delete(id))
            {
            case DAL.Extensions.DataBaseResult.Success:
                result.Errors.Add("Randevu silindi");
                result.Result = Extensions.BLLResult.Success;
                break;

            case DAL.Extensions.DataBaseResult.Referanced:
                result.Errors.Add("Silinmeye çalışılan randevu muayene olduğundan randevu silinemedi.");
                result.Result = Extensions.BLLResult.Referanced;
                break;

            case DAL.Extensions.DataBaseResult.NotFound:
                result.Errors.Add("Randevu bulunamadı");
                result.Result = Extensions.BLLResult.NotFound;
                break;

            case DAL.Extensions.DataBaseResult.Error:
                result.Errors.Add("Randevu silinirken bir hata ile karşılaşıldı");
                result.Result = Extensions.BLLResult.Error;
                break;

            case DAL.Extensions.DataBaseResult.ServerDisable:
                result.Result = Extensions.BLLResult.ServerDisable;
                result.Errors.Add(Extensions.ServerDisable);
                break;

            case DAL.Extensions.DataBaseResult.AlreadyFound:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            return(result);
        }
Exemplo n.º 2
0
        public ProcessResult Insert(Prescription newPrescription)
        {
            ExaminationManager manager = new ExaminationManager();
            ProcessResult      result  = VerifyPrescription(newPrescription);

            if (result.Result == Extensions.BLLResult.NotVerified)
            {
                return(result);
            }

            Examination examination = manager.Select(newPrescription.Examination.Id);

            examination.DiagnosisId    = newPrescription.Examination.DiagnosisId;
            examination.IsActive       = false;
            examination.DoctorNote     = newPrescription.Examination.DoctorNote;
            examination.CanSendMessage = newPrescription.Examination.CanSendMessage;
            examination.NextTime       = newPrescription.Examination.NextTime;

            newPrescription.Examination = null;
            if (_prescriptionDal.Insert(newPrescription))
            {
                bool update = manager.Update(examination);
                if (update)
                {
                    result.Result = Extensions.BLLResult.Success;
                    result.Errors.Add("Reçete başarı ile oluşturuldu ve muayene kapandı");
                }
                else
                {
                    result.Result = Extensions.BLLResult.Error;
                    result.Errors.Add("Reçete oluşturulamadı");
                }
            }
            else
            {
                result.Result = Extensions.BLLResult.Error;
                result.Errors.Add("Reçete oluşturulamadı");
            }
            return(result);
        }
        public ProcessResult Insert(Rendezvous newRendezvous, bool toExamination)
        {
            newRendezvous.IsActive = !toExamination;
            newRendezvous.Date     = toExamination ? DateTime.Today : newRendezvous.Date;

            ProcessResult result = Verifyrendezvous(newRendezvous);

            if (result.Result != Extensions.BLLResult.Verified)
            {
                return(result);
            }

            result = IsHoliday(newRendezvous.Date);
            if (result.Result != Extensions.BLLResult.Success)
            {
                return(result);
            }

            result = IsExistOtherRendezvous(newRendezvous);
            if (result.Result == Extensions.BLLResult.AlreadyFound)
            {
                return(result);
            }

            DAL.Extensions.DataBaseResult baseResult = _rendezvousDal.Insert(ref newRendezvous);

            switch (baseResult)
            {
            case DAL.Extensions.DataBaseResult.Error:
                result.Errors.Add(Extensions.InnerException);
                result.Result = Extensions.BLLResult.InnerException;
                break;

            case DAL.Extensions.DataBaseResult.ServerDisable:
                result.Result = Extensions.BLLResult.ServerDisable;
                result.Errors.Add(Extensions.ServerDisable);
                break;

            case DAL.Extensions.DataBaseResult.Success:
                break;

            case DAL.Extensions.DataBaseResult.AlreadyFound:
                break;

            case DAL.Extensions.DataBaseResult.Referanced:
                break;

            case DAL.Extensions.DataBaseResult.NotFound:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            if (toExamination)
            {
                DiagnosisManager   diagnosisManager = new DiagnosisManager();
                Diagnosis          diagnosis        = diagnosisManager.GetDefaultDiagnosis();
                ExaminationManager manager          = new ExaminationManager();
                manager.Insert(new Examination
                {
                    CanSendMessage = false, PatientId = newRendezvous.PatientId, DoctorId = newRendezvous.DoctorId, Time = newRendezvous.Date, RendezvousId = newRendezvous.Id, IsActive = true, DiagnosisId = diagnosis.Id
                });
            }

            result.Errors.Add(Extensions.SuccessProcess);
            result.Errors.Add(String.Format("Kayıt numarası: {0}", newRendezvous.Id));
            result.Result = Extensions.BLLResult.Success;
            return(result);
        }