public async Task <bool> UploadFile([FromForm] IFormFile file, [FromForm] int idImovel) { _imovelBLL = new ImovelBLL(); try { if (file.Length > 0) { var filePath = Directory.GetCurrentDirectory(); string filePathSalvar = "Resources\\img\\idImovel-" + idImovel; filePath += "\\" + filePathSalvar; DirectoryInfo di = Directory.CreateDirectory(filePath); using (var stream = new FileStream(filePath + "\\" + file.FileName, FileMode.Create)) { await file.CopyToAsync(stream); ImagensImovel ii = new ImagensImovel(); ii.dataInsert = DateTime.Now; ii.idImovelImagem = idImovel; ii.name = file.FileName; ii.path = filePathSalvar + "\\" + ii.name; _imovelBLL.InsertFile(ii); } return(true); } return(false); } catch (Exception ex) { throw ex; } }
internal void DeleteFile(ImagensImovel file) { using (MySqlConnection conexao = new MySqlConnection( DBConnection.Configuration.GetConnectionString("imobiliariadb"))) { conexao.Delete(file); } }
internal void InsertFile(ImagensImovel file) { using (MySqlConnection conexao = new MySqlConnection( DBConnection.Configuration.GetConnectionString("imobiliariadb"))) { file.dataInsert = DateTime.Now; file.idImagensImovel = GetLastIdImagem(conexao) + 1; conexao.Insert(file); } }
void DeleteFIle(ImagensImovel file) { _imovelBLL.DeleteFile(file); var filePath = Directory.GetCurrentDirectory(); filePath += "\\" + file.path; if (System.IO.File.Exists(filePath)) { System.IO.File.Delete(filePath); } }
public bool DeleteFile([FromBody] ImagensImovel file) { _imovelBLL = new ImovelBLL(); try { DeleteFIle(file); _imovelBLL.DeleteFile(file); return(true); } catch (Exception ex) { throw ex; } }
internal void InsertFile(ImagensImovel file) { _dao.InsertFile(file); }
internal void DeleteFile(ImagensImovel file) { _dao.DeleteFile(file); }