public ICommandResult Handle(GetObjectTypeCommand command) { ICommandResult result = new GetObjectTypeCommandResult(); _loggingService.Log(this.GetType(), ELogType.Neutral, ELogLevel.Debug, new { command.ObjectType, command.RequestHost }, "ObjectTypeCommandHandler.Handle(Get)"); try { if (_objectTypeRepository.CheckExists(command.ObjectType)) { ObjectType objectType = _objectTypeRepository.Get(command.ObjectType); if (objectType != null) { result = new GetObjectTypeCommandResult(200, objectType.Name); } } else if (_objectTypeRepository.Valid) { result = new GetObjectTypeCommandResult(400, new Notification("Object Type", "Could not be found")); } } catch (Exception e) { _loggingService.Log(this.GetType(), ELogType.Neutral, ELogLevel.Error, new { command.ObjectType, command.RequestHost }, e); } return(result); }
public GetObjectTypeCommandResult Get(Guid id) { GetObjectTypeCommand command = new GetObjectTypeCommand() { ObjectType = id }; command.setRequestHost(HttpContext.Request.Host.ToString()); _loggingService.Log(this.GetType(), ELogType.Input, ELogLevel.Info, new { ObjectType = this.User.Identity.Name, Path = this.Request.Path, Method = this.Request.Method }); GetObjectTypeCommandResult result = (GetObjectTypeCommandResult)_objectTypeHandler.Handle(command); _loggingService.Log(this.GetType(), ELogType.Output, ELogLevel.Info, new { ObjectType = this.User.Identity.Name, Path = this.Request.Path, Method = this.Request.Method, Code = this.Response.StatusCode }); HttpContext.Response.StatusCode = result.Code; return(result); }