public ICommandResult Handle(GetObjectStatusCommand command) { ICommandResult result = new GetObjectStatusCommandResult(); _loggingService.Log(this.GetType(), ELogType.Neutral, ELogLevel.Debug, new { command.ObjectStatus, command.RequestHost }, "ObjectStatusCommandHandler.Handle(Get)"); try { if (_objectStatusRepository.CheckExists(command.ObjectStatus)) { ObjectStatus objectStatus = _objectStatusRepository.Get(command.ObjectStatus); if (objectStatus != null) { result = new GetObjectStatusCommandResult(200, objectStatus.Name); } } else if (_objectStatusRepository.Valid) { result = new GetObjectStatusCommandResult(400, new Notification("Object Status", "Could not be found")); } } catch (Exception e) { _loggingService.Log(this.GetType(), ELogType.Neutral, ELogLevel.Error, new { command.ObjectStatus, command.RequestHost }, e); } return(result); }
public GetObjectStatusCommandResult Get(Guid id) { GetObjectStatusCommand command = new GetObjectStatusCommand() { ObjectStatus = id }; command.setRequestHost(HttpContext.Request.Host.ToString()); _loggingService.Log(this.GetType(), ELogType.Input, ELogLevel.Info, new { ObjectStatus = this.User.Identity.Name, Path = this.Request.Path, Method = this.Request.Method }); GetObjectStatusCommandResult result = (GetObjectStatusCommandResult)_objectStatusHandler.Handle(command); _loggingService.Log(this.GetType(), ELogType.Output, ELogLevel.Info, new { ObjectStatus = this.User.Identity.Name, Path = this.Request.Path, Method = this.Request.Method, Code = this.Response.StatusCode }); HttpContext.Response.StatusCode = result.Code; return(result); }