public HttpResponseMessage UserFileAdd(JObject jsonData) { dynamic json = jsonData; try { var userFile = new AddUserFileCommand() { UserFileId = (int)json.UserFileId, UserId = (int)json.UserId, FileId = Convert.ToInt64(json.FileId), AssociatedDateUTC = DateTime.UtcNow, Active = true }; this.bus.Send(userFile); return(Request.CreateResponse(HttpStatusCode.OK)); } catch (System.Exception e) { LogManager.Error("Erro ao Add UserFileAdd", e); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e)); } }
public void Handle(UserCreatedFIleEvent @event) { FIleServer fs = new FIleServer(); fs.FilePath = @event.FilePath; fs.Width = @event.Width; fs.Height = @event.Height; fs.OriginalName = @event.OriginalName; fs.FileTempId = @event.FileTempId; fs.Description = @event.Description; fs.FriendlyName = @event.FriendlyName; fs.Alt = @event.Alt; fs.Name = @event.Name; fs.FileOriginTypeId = @event.FileOriginTypeId; fs.PersonId = @event.PersonId; fs.FileUtilizationId = @event.FileUtilizationId; fs.UploadedBy = @event.UploadedBy; var ret = fs.SendFilePath(fs); if (ret > 0) { _FileTemp.Delete(fs.FileTempId); var userFileCommand = new AddUserFileCommand() { FileId = ret, AssociatedDateUTC = DateTime.UtcNow, Active = true, UserId = @event.UserId }; this.bus.Send(userFileCommand); } else { throw new Exception(); } }