public ICommandResult Handle(DeleteObjectTypeCommand command) { ICommandResult result = new CommandResult(); _loggingService.Log(this.GetType(), ELogType.Neutral, ELogLevel.Debug, new { command.ObjectType, command.RequestHost }, "ObjectTypeCommandHandler.Handle(Delete)"); try { if (_objectTypeRepository.CheckExists(command.ObjectType)) { if (_objectTypeRepository.Delete(command.ObjectType)) { result = new CommandResult(200); } } else if (_objectTypeRepository.Valid) { result = new CommandResult(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 CommandResult Delete(Guid id) { DeleteObjectTypeCommand command = new DeleteObjectTypeCommand() { 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 }); CommandResult result = (CommandResult)_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); }