/// <summary> /// Valida las extensiones permitidas de un archivo /// </summary> /// <param name="fileExtension">Extensión del archivo</param> /// <returns></returns> public bool ValidateFileExtension(IFormFile file) { string fileExtension = Path.GetExtension(file.FileName); var allowedFileExtensions = config.GetVal("Appsettings:AllowedFileExtensions"); return(allowedFileExtensions.Contains(fileExtension.ToLower())); }
/// <summary> /// Permite guardar la imagen al blob storage /// </summary> /// <param name="imageName">Nombre de la imagen</param> /// <param name="fileByteArray">Array de bytes de la imagen</param> /// <returns></returns> private async Task <string> SaveFileToBlobAsync(string imageName, byte[] fileByteArray) { blobStorageService.StorageConnectionString = config.GetVal("Blob:StorageConnection"); blobStorageService.ContainerName = config.GetVal("Blob:BlobContainerProvider"); var uploadImage = new UploadFile { FileName = imageName, ByteArray = fileByteArray }; return(await blobStorageService.SaveFileAsync(uploadImage).ConfigureAwait(false)); }
public async Task <IList <Employee> > GetEmployeeList() { string urlApiEmployees = _configuration.GetVal("UrlEmployees"); var employess = await _httpClient.GetData <List <Employee> >(urlApiEmployees).ConfigureAwait(false); return(employess); }
public async Task SendMessage(string queue, Message msg) { try { SbQueueClient = new QueueClient(config.GetVal("ServiceBus:Endpoint"), config.GetVal("Queues:" + queue)); await SbQueueClient.SendAsync(msg); } catch (Exception ex) { throw new Exception(ex.Message); } }
public ActionResult GetStates() { try { var parametersStates = config.GetVal("Appsettings:ParametersStates").Split(','); var states = stateService.GetStates(parametersStates); return(new OkObjectResult(states)); } catch (Exception ex) { log.Error($"Ocurrió un error al consultar los estados: {ex.Message}"); return(StatusCode(HttpStatusCode.InternalServerError.GetHashCode(), ex.Message)); } }