public ICommandResult Handle(GetObjectCommand command) { ICommandResult result = new GetObjectCommandResult(); _loggingService.Log(this.GetType(), ELogType.Neutral, ELogLevel.Debug, new { command.Object, command.RequestHost }, "ObjectCommandHandler.Handle(Get)"); try { if (_objectRepository.CheckExists(command.Object)) { Object obj = _objectRepository.Get(command.Object); if (obj != null) { result = new GetObjectCommandResult(200, obj.Title, obj.Description, obj.Creator, obj.Father, obj.Path, obj.Type, obj.Status, obj.CreationDate); } } else if (_objectRepository.Valid) { result = new GetObjectCommandResult(400, new Notification("Object", "Could not be found")); } } catch (Exception e) { _loggingService.Log(this.GetType(), ELogType.Neutral, ELogLevel.Error, new { command.Object, command.RequestHost }, e); } return(result); }
public GetObjectCommandResult Get(Guid id) { GetObjectCommand command = new GetObjectCommand() { Object = id }; command.setRequestHost(HttpContext.Request.Host.ToString()); _loggingService.Log(this.GetType(), ELogType.Input, ELogLevel.Info, new { Object = this.User.Identity.Name, Path = this.Request.Path, Method = this.Request.Method }); GetObjectCommandResult result = (GetObjectCommandResult)_objectHandler.Handle(command); _loggingService.Log(this.GetType(), ELogType.Output, ELogLevel.Info, new { Object = this.User.Identity.Name, Path = this.Request.Path, Method = this.Request.Method, Code = this.Response.StatusCode }); HttpContext.Response.StatusCode = result.Code; return(result); }