public async Task <IActionResult> UploadFiles(List <IFormFile> files, string accountUrl, string container, string prefix = null) { var response = new JsonResult <List <FileUploadResult> >() { Success = false, Result = new List <FileUploadResult>() }; if (!GenericCheck(() => _TokenService.HasToken, response, StatusCodes.Status401Unauthorized, SiteErrorCodes.NotAuthorized, () => Url.RouteUrl(Routes.GET_Home_Route))) { return(Json(response)); } if ((files?.Count ?? 0) == 0) { response.Success = false; response.StatusCode = StatusCodes.Status400BadRequest; response.ErrorCode = ErrorCodes.FromUploadStatus(UploadService.UploadStatus.NoFileProvided).ErrorCode; return(JsonResult(response)); } //var file = files.FirstOrDefault(); var res = await _UploadService.AddFiles(files, accountUrl, container, prefix); if (res.All(s => s.status != UploadService.UploadStatus.Ok)) { response.Success = false; var statuss = from r in res where r.status != UploadService.UploadStatus.Ok select ErrorCodes.FromUploadStatus(r.status); response.StatusCode = statuss.FirstOrDefault().StatusCode; response.ErrorCodes = statuss.Select(s => s.ErrorCode).ToList(); return(JsonResult(response)); } response.Success = true; response.StatusCode = StatusCodes.Status200OK; foreach (var f in res.Where(r => r.file != null).Select(r => r.file)) { response.Result.Add(new FileUploadResult() { //FileId = f.Id, FileName = f.FileName, SizeKB = (int)(f.Size / 1024) }); } return(JsonResult(response)); }