Ejemplo n.º 1
0
        public FileResponseDTO Update(UpdateFileRequestDTO requestDTO)
        {
            if (this.FindOneByUUID(requestDTO.uuid) == null)
            {
                throw new EntityNotFoundException($"File with uuid {requestDTO.uuid} doesn't exist!", GeneralConsts.MICROSERVICE_NAME);
            }

            Domain.File file = new Domain.File()
            {
                uuid = requestDTO.uuid
            };

            file.filePath = CreateRelativeFilePath(file.uuid, requestDTO.fileExtension);
            DeleteFile(file.filePath);
            SaveFile(requestDTO.fileData, file.filePath);

            file = this._queryExecutor.Execute <Domain.File>(DatabaseConsts.USER_SCHEMA, this._sqlCommands.UPDATE_FILE(file), this._modelMapper.MapToFile);
            try
            {
                var mat = this._httpClientService.SendRequest <object>(HttpMethod.Put, "http://localhost:40008/api/sections/material/", new UserPrincipal(_httpContextAccessor.HttpContext).token, file).Result;
            } catch {}

            try
            {
                var message = this._httpClientService.SendRequest <object>(HttpMethod.Put, "http://localhost:40002/api/messaging/file/", new UserPrincipal(_httpContextAccessor.HttpContext).token, file).Result;
            }
            catch { }
            return(this._autoMapper.Map <FileResponseDTO>(file));
        }
Ejemplo n.º 2
0
 public ActionResult <FileResponseDTO> HandleUpdateFile(UpdateFileRequestDTO requestDTO)
 {
     return(Ok(this._fileService.Update(requestDTO)));
 }