Beispiel #1
0
        /// <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()));
        }
Beispiel #2
0
        /// <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));
        }
Beispiel #3
0
        public async Task <IList <Employee> > GetEmployeeList()
        {
            string urlApiEmployees = _configuration.GetVal("UrlEmployees");
            var    employess       = await _httpClient.GetData <List <Employee> >(urlApiEmployees).ConfigureAwait(false);

            return(employess);
        }
Beispiel #4
0
 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);
     }
 }
Beispiel #5
0
 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));
     }
 }