public IActionResult GetAll(long IdReception) { List <string> lst = new List <string>(); ContextDb db = new ContextDb(); var reception = db.tblReceptions.FirstOrDefault(c => c.Id == IdReception); string path = string.Empty; string base64 = string.Empty; if (!string.IsNullOrEmpty(reception.PenSatisfaction)) { path = Path.Combine(_hostingEnvironment.WebRootPath, "FileUpload", reception.PenSatisfaction); // byte[] b = System.IO.File.ReadAllBytes(path); base64 = MYHelper.getbase64(path); lst.Add(base64); } var xx = db.tblVisits.Where(c => c.IdReception == IdReception).Select(c => c.Id).ToArray(); foreach (var pic in db.tblPictures.Where(c => xx.Contains(c.IdVisit)).OrderBy(c => c.IdVisit)) { path = Path.Combine(_hostingEnvironment.WebRootPath, "FileUpload", pic.Filepath); // byte[] b = System.IO.File.ReadAllBytes(path); base64 = MYHelper.getbase64(path); lst.Add(base64); } return(Ok(lst)); }
public async Task <IEnumerable <tblPicture> > GetAll(long IdReception, string date) { long idVisit = MYHelper.getIdVisitbyIdReception(IdReception, date); var result = await repository.GetAll(c => c.IdVisit == idVisit); result.ToList().ForEach(c => { c.Filepath = MYHelper.getbase64(Path.Combine(_hostingEnvironment.WebRootPath, "FileUpload", c.Filepath)); }); return(result); }