// TODO: Put in options from external call like in Load /// <inheritdoc /> public async Task <SaveResult> SaveFile(IStateInfo stateInfo, IFileSystem fileSystem, UPath savePath) { lock (_loadedFilesLock) ContractAssertions.IsElementContained(_loadedFiles, stateInfo, "loadedFiles", nameof(stateInfo)); var isRunning = Progress.IsRunning(); if (!isRunning) { Progress.StartProgress(); } var saveResult = await _fileSaver.SaveAsync(stateInfo, fileSystem, savePath, new SaveInfo { Progress = Progress, DialogManager = DialogManager, Logger = Logger }); if (!isRunning) { Progress.FinishProgress(); } return(saveResult); }
public async Task <IActionResult> Post( [FromServices] IFileSaver fileSaver, [FromServices] IConfiguration configuration, [FromForm] ProductAddCommand command, ApiVersion version ) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (command.Photo != null && command.Photo.Length > 0) { command.PhotoName = await fileSaver.SaveAsync(command.Photo, configuration["Settings:ProductPhotoDirectory"]); } var id = await _mediator.Send(command); await _unitOfWork.CommitAsync(); return(CreatedAtAction(nameof(Get), new { id, Version = $"{version}" }, new ProductDto { Id = id })); }
public async Task <TeamMember> SaveAsync(string WRpath, string uploadFolderName, TeamMemberData ourTeamMemberData) { var responseAvatarFile = await _fileSaver.SaveAsync(WRpath, uploadFolderName, ourTeamMemberData.avatarFile); var responseImageFile = await _fileSaver.SaveAsync(WRpath, uploadFolderName, ourTeamMemberData.imageFile); if (responseAvatarFile != "Failed" || responseImageFile != "Failed") { var teamMember = new TeamMember { AvatarUrl = responseAvatarFile, FullName = ourTeamMemberData.fullName, Activity = ourTeamMemberData.activity, ImageUrl = responseImageFile, Description = ourTeamMemberData.description, Moto = ourTeamMemberData.moto }; return(await _ourTeamMemberRepository.AddAsync(teamMember)); } return(null); }
/// <inheritdoc /> public async Task <SaveResult> SaveFile(IStateInfo stateInfo, IFileSystem fileSystem, UPath savePath) { lock (_loadedFilesLock) { ContractAssertions.IsElementContained(_loadedFiles, stateInfo, "loadedFiles", nameof(stateInfo)); } var isRunning = _progress.IsRunning(); if (!isRunning) { _progress.StartProgress(); } var saveResult = await _fileSaver.SaveAsync(stateInfo, fileSystem, savePath, _progress); if (!isRunning) { _progress.FinishProgress(); } return(saveResult); }
public override async Task <string> Execute(FileRequest request) { var fileId = await _fileStorage.SaveAsync(request.File, request.FileName); var newFileRecord = new PersonalDocument() { FileUrl = fileId, Name = request.FileName, UserId = request.UserId, ContentType = request.ContentType }; await _dbContext.PersonalDocuments.AddAsync(newFileRecord); await _dbContext.SaveChangesAsync(); return(fileId); }
public async Task <GymSessionSchedule> SaveAsync(string WRpath, string uploadFolderName, ScheduleUploadData scheduleUploadData) { var response = await _fileSaver.SaveAsync(WRpath, uploadFolderName, scheduleUploadData.file); if (response != "Failed") { var schedule = new GymSessionSchedule { DayOfWeek = scheduleUploadData.dayOfWeek, ImageUrl = response, Description = scheduleUploadData.description, Time = scheduleUploadData.hourMinute, Practice = scheduleUploadData.practice }; return(await _gymSessionScheduleRepository.AddAsync(schedule)); } return(null); }