コード例 #1
0
        public List <ThuocDieuTriBenhDTO> GetAll()
        {
            var lstThuocDieuTri     = _thuocdieutriRepository.GetAll().ToList();
            var lstThuocDieuTriDtos = _mapper.Map <List <ThuocDieuTriBenhDTO> >(lstThuocDieuTri);

            foreach (var item in lstThuocDieuTriDtos)
            {
                var thuoc = _thuocService.GetById(item.MaThuoc.ToString());
                item.Thuoc = _mapper.Map <ThuocDTO>(thuoc);

                var benh = _benhService.GetById(item.MaBenh.ToString());
                item.Benh = _mapper.Map <BenhDTO>(benh);
            }
            return(lstThuocDieuTriDtos);
        }
コード例 #2
0
 public async Task <BaseResponse <ThuocDTO> > GetById(string mathuoc)
 {
     try
     {
         var result = _thuocService.GetById(mathuoc);
         if (result != null)
         {
             return(await Task.FromResult(new BaseResponse <ThuocDTO>(result)));
         }
         return(await Task.FromResult(new BaseResponse <ThuocDTO>(Message.GetDataNotSuccess)));
     }
     catch (Exception e)
     {
         return(await Task.FromResult(new BaseResponse <ThuocDTO>(Message.GetDataNotSuccess)));
     }
 }
コード例 #3
0
        public async Task <BaseResponse <List <ThuocDTO> > > GetThuocOfBenh(string mabenh)
        {
            try
            {
                List <ThuocDieuTriBenhDTO> lstThuocdieutris  = _thuocdieutriService.GetListByMaBenh(mabenh);
                List <ThuocDTO>            thuocdieutriModel = new List <ThuocDTO>();

                foreach (var thuocdieutri in lstThuocdieutris)
                {
                    var thuoc = _thuocService.GetById(thuocdieutri.MaThuoc.ToString());
                    thuocdieutriModel.Add(thuoc);
                }

                return(await Task.FromResult(new BaseResponse <List <ThuocDTO> >(thuocdieutriModel, true)).ConfigureAwait(false));
            }
            catch
            {
                return(await Task.FromResult(new BaseResponse <List <ThuocDTO> >(Message.GetDataNotSuccess, false)).ConfigureAwait(false));
            }
        }