public ActionResult UpdateFile(Guid id, FileUpdateDto fileUpdateDto) { if (!Request.Headers.ContainsKey("token")) { return(Unauthorized()); } var auth = Request.Headers["token"]; var accountModel = _validate.GetAccountByToken(auth); if (accountModel == null) { return(Unauthorized()); } var fileModelFromRepo = _repository.GetFileById(id, accountModel.Id); if (fileModelFromRepo == null) { return(NotFound()); } _mapper.Map(fileUpdateDto, fileModelFromRepo); _repository.UpdateFile(fileModelFromRepo); _repository.SaveChanges(); return(NoContent()); }
public OperationResult EditSco(string scoId, FileUpdateDto dto) { if (string.IsNullOrWhiteSpace(scoId)) { throw new ArgumentException("Non-empty value expected", nameof(scoId)); } if (dto == null) { throw new ArgumentNullException(nameof(dto)); } try { ScoInfoResult scoResult = _acProxy.GetScoInfo(scoId); if (!scoResult.Success) { if (scoResult.Status.Code == StatusCodes.no_access && scoResult.Status.SubCode == StatusSubCodes.denied) { return(OperationResult.Error(Resources.Messages.AccessDenied)); } throw new AdobeConnectException(scoResult.Status); } ScoInfoResult updatedSco = _acProxy.UpdateSco( new FolderUpdateItem { Name = dto.Name, Description = dto.Description, ScoId = scoId, Type = scoResult.ScoInfo.Type, }); if (!updatedSco.Success) { return(OperationResult.Error(updatedSco.Status.GetErrorInfo())); } return(OperationResult.Success()); } catch (AdobeConnectException ex) { if (ex.Status.Code == StatusCodes.no_access && ex.Status.SubCode == StatusSubCodes.denied) { return(OperationResult.Error(Resources.Messages.AccessDenied)); } string errorMessage = GetOutputErrorMessage("EditSco", ex); return(OperationResult.Error(errorMessage)); } catch (Exception ex) { string errorMessage = GetOutputErrorMessage("EditSco", ex); return(OperationResult.Error(errorMessage)); } }
public OperationResult EditSco(string scoId, [FromBody] FileUpdateDto dto) { try { var ac = this.GetUserProvider(); var helper = new ContentEditControllerHelper(Logger, ac); return(helper.EditSco(scoId, dto)); } catch (Exception ex) { string errorMessage = GetOutputErrorMessage("ContentApi-EditFile", ex); return(OperationResult.Error(errorMessage)); } }
public async Task <int> Update(FileUpdateDto dto, int id, string userId) { var oldFile = await _dbContext.Files .Include(x => x.Transaction).SingleOrDefaultAsync(x => x.Id == id); var updatedFile = _mapper.Map(dto, oldFile); updatedFile.FilePath = await _storageService.SaveFile(dto.File, $"Transaction{dto.TransactionId}", dto.FileExtension); _dbContext.Files.Update(updatedFile); await _dbContext.SaveChangesAsync(); return(updatedFile.Id); }
public OperationResult EditSco(string scoId, [FromBody] FileUpdateDto dto) { if (dto == null) { throw new ArgumentNullException(nameof(dto)); } try { if (!LmsCompany.GetSetting <bool>(LmsCompanySettingNames.EnableMyContent)) { return(OperationResult.Error("Operation is not enabled.")); } var ac = this.GetUserProvider(); var helper = new ContentEditControllerHelper(Logger, ac); return(helper.EditSco(scoId, dto)); } catch (Exception ex) { string errorMessage = GetOutputErrorMessage("ContentApi-EditFile", ex); return(OperationResult.Error(errorMessage)); } }
public async Task <IActionResult> Update([FromBody] FileUpdateDto dto, int id) => await GetResponse(async (userId) => new ApiResponseViewModel(true, "File Updated Successfully", await _service.Update(dto, id, userId)));