Example #1
0
 public RequestorDTO GetById(string id)
 {
     return(requestorFactory.createDTO(requestorRepository.findByIdAsync(id).Result));
 }
Example #2
0
        private CaseDTO GetCaseDTO(Case c)
        {
            CaseDTO caseDTO = new CaseDTO();

            caseDTO.Id        = c.Id;
            caseDTO.Type      = c.Type;
            caseDTO.CaseId    = c.CaseId;
            caseDTO.CreatedOn = c.CreatedOn;
            caseDTO.Status    = c.Status;

            DateTime closedOn = c.ClosedOn;

            if (c.ClosedOn == null || c.ClosedOn.Equals(new DateTime()))
            {
                closedOn = DateTime.Now;
            }


            TimeSpan span = (closedOn - c.CreatedOn);

            caseDTO.OpenTime = String.Format("{0} days, {1} hours, {2} minutes, {3} seconds",
                                             span.Days, span.Hours, span.Minutes, span.Seconds);


            try {
                if (c.RequestorId != null && c.RequestorId != "")
                {
                    RequestorDTO r = requestorFactory.createDTO(requestorRepository.findByIdAsync(c.RequestorId).Result);
                    caseDTO.Requestor = requestorFactory.createDTO(requestorRepository.findByIdAsync(c.RequestorId).Result);
                }
            } catch (DocumentClientException e) {
                Console.WriteLine(e.Message);
            } catch (AggregateException e) {
                Console.WriteLine(e.Message);
            }

            try {
                if (c.PatientId != null && c.PatientId != "")
                {
                    caseDTO.Patient = patientFactory.createDTO(patientRepository.findByIdAsync(c.PatientId).Result);
                }
            } catch (DocumentClientException e) {
                Console.WriteLine(e.Message);
            } catch (AggregateException e) {
                Console.WriteLine(e.Message);
            }


            try {
                if (c.Specimens != null)
                {
                    List <Specimen> spcis = specimenRepository.ListAsync(c.Specimens).Result;
                    caseDTO.Specimens = specimenFactory.create(spcis);
                }
            } catch (DocumentClientException e) {
                Console.WriteLine(e.Message);
            } catch (AggregateException e) {
                Console.WriteLine(e.Message);
            }

            return(caseDTO);
        }