public IActionResult viewphoto(ContactMasterNewDTO 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.pContactimagepath)); 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.pPhoto = base64String; } } } } catch (Exception ex) { throw new FinstaAppException(ex.ToString()); } return(Ok(base64String)); }
public int GetPersonCount(ContactMasterNewDTO ContactDto) { try { return(obj.GetPersoncount(ContactDto, Con)); } catch (Exception ex) { throw new FinstaAppException(ex.ToString()); } }
public bool DeleteContact(ContactMasterNewDTO contact) { try { return(obj.DeleteContact(contact, Con)); } catch (Exception ex) { throw new FinstaAppException(ex.ToString()); } }
public ContactMasterNewDTO ViewContact(string refernceid) { lstcontactMasterDetails = new ContactMasterNewDTO(); try { lstcontactMasterDetails = obj.ViewContact(refernceid, Con); if (!string.IsNullOrEmpty(lstcontactMasterDetails.pContactimagepath)) { viewphoto(lstcontactMasterDetails); } } catch (Exception ex) { throw new FinstaAppException(ex.ToString()); } return(lstcontactMasterDetails); }
public bool Uploadphoto(ContactMasterNewDTO contact) { try { var bytes = Convert.FromBase64String(contact.pPhoto); // a.base64image //or full path to file in temp location //var filePath = Path.GetTempFileName(); // full path to file in current project location string filedir = Path.Combine(Directory.GetCurrentDirectory(), "ContactImages"); Debug.WriteLine(filedir); Debug.WriteLine(Directory.Exists(filedir)); if (!Directory.Exists(filedir)) { //check if the folder exists; Directory.CreateDirectory(filedir); } Guid obj = Guid.NewGuid(); string file1 = Path.Combine(filedir, obj.ToString() + contact.pBusinesscontactName + ".jpg"); contact.pContactimagepath = file1; Debug.WriteLine(file1); //Debug.WriteLine(File.Exists(file)); if (bytes.Length > 0) { using (var stream = new FileStream(file1, FileMode.Create)) { stream.Write(bytes, 0, bytes.Length); stream.Flush(); } return(true); } else { return(false); } } catch (Exception ex) { //return StatusCode(500, "Internal server error"); //throw ex; throw new FinstaAppException(ex.ToString()); } }
public IActionResult UpdateContact([FromBody] ContactMasterNewDTO contact) { bool issaved = false; List <string> lstdata = new List <string>(); try { string contactId = string.Empty; issaved = obj.UpdateContact(contact, out contactId, Con); lstdata.Add(issaved.ToString().ToUpper()); lstdata.Add(contactId); return(Ok(lstdata)); // return Ok(issaved); } catch (Exception ex) { throw new FinstaAppException(ex.ToString()); } }