private string OutExcelByIdKhachHang(int id)
        {
            var    folderReport = "/Reports";
            string filePath     = HttpContext.Current.Server.MapPath(folderReport);

            if (!Directory.Exists(filePath))
            {
                Directory.CreateDirectory(filePath);
            }
            // template File
            string templateDocument = HttpContext.Current.Server.MapPath("~/Reports/TemplateForReport/ReportLinhHaDetail.xlsx");
            string documentName     = string.Format("BaoCaoLinhHa-{0}-{1}.xlsx", id, DateTime.Now.ToString("ddmmyyyyss"));
            string fullPath         = Path.Combine(filePath, documentName);
            //result Output
            MemoryStream output = new MemoryStream();

            //read template
            FileStream     templateDocumentStream = File.OpenRead(templateDocument);
            ExcelPackage   package = new ExcelPackage(templateDocumentStream);
            ExcelWorksheet sheet   = package.Workbook.Worksheets["Sheet1"];
            var            kh      = _khachHangService.GetDetail(id);

            sheet.Cells[7, 2, 7, 3].Value = kh.Name;
            sheet.Cells[8, 2].Value       = kh.Address;
            sheet.Cells[9, 2].Value       = kh.Id;
            sheet.Cells[10, 2].Value      = kh.PhoneNumber;
            sheet.Cells[5, 10].Value      = DateTime.Now.ToString("dd/MM/yyyy");



            var khachhang = _chitietKhachHangService.GetMultilById(id);

            int     i = 0;
            decimal totalCountMoney = 0;

            foreach (var item in khachhang)
            {
                totalCountMoney             += item.CTNoLai;
                sheet.Cells[8 + i, 6].Value  = i;
                sheet.Cells[8 + i, 7].Value  = item.NgayChuaBenh.ToString("dd/MM/yyyy");
                sheet.Cells[8 + i, 8].Value  = item.ChiPhiChuaBenh;
                sheet.Cells[8 + i, 9].Value  = item.CTNoLai;
                sheet.Cells[8 + i, 10].Value = "Quá dài";
                i++;
            }
            sheet.Cells[11, 2, 14, 3].Value = totalCountMoney;


            package.SaveAs(new FileInfo(fullPath));
            return(documentName);
        }
        public HttpResponseMessage GetDetailById(HttpRequestMessage request, int id)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;
                var model = _khachHangService.GetDetail(id);
                if (model == null)
                {
                    response = request.CreateResponse(HttpStatusCode.BadRequest, "no data");
                }
                else
                {
                    var mapper = Mapper.Map <KhachHang, KhachHangViewModel>(model);
                    response = request.CreateResponse(HttpStatusCode.OK, mapper);
                }

                return response;
            }));
        }