public IActionResult viewphoto1(ContactViewNewDTO contact) { string base64String = string.Empty; string filePath = string.Empty; try { string ThumbnailFolder = "Upload\\"; string webRootPath = _hostingEnvironment.ContentRootPath; string ThumabnailsFolderpath = Path.Combine(webRootPath, ThumbnailFolder); string ThumbnailFullPath = Path.Combine(ThumabnailsFolderpath, Convert.ToString(contact.pImagePath)); if (System.IO.File.Exists(ThumbnailFullPath)) { using (System.Drawing.Image image = System.Drawing.Image.FromFile(ThumbnailFullPath)) { using (MemoryStream m = new MemoryStream()) { image.Save(m, image.RawFormat); byte[] imageBytes1 = m.ToArray(); base64String = Convert.ToBase64String(imageBytes1); contact.pImage = base64String; } } } } catch (Exception ex) { throw new FinstaAppException(ex.ToString()); } return(Ok(base64String)); }
public IActionResult GetContactViewbyid(string refid) { ContactViewNewDTO lstContactViewDTO = new ContactViewNewDTO(); try { lstContactViewDTO = obj.GetContactViewbyid(Con, refid); if (!string.IsNullOrEmpty(lstContactViewDTO.pContactimagepath)) { viewphoto1(lstContactViewDTO); } } catch (Exception ex) { throw new FinstaAppException(ex.ToString()); } return(Ok(lstContactViewDTO)); }