public ICommandResult Handle(NewObjectTypeCommand command) { ICommandResult result = new NewObjectTypeCommandResult(); _loggingService.Log(this.GetType(), ELogType.Neutral, ELogLevel.Debug, new { command.Name, command.RequestHost }, "ObjectTypeCommandHandler.Handle(New)"); try { ObjectType objectType = new ObjectType(command.Name); if (objectType.Valid) { if (!_objectTypeRepository.CheckExists(objectType.Name)) { if (_objectTypeRepository.Create(objectType)) { result = new NewObjectTypeCommandResult(200, objectType.Id); } } else if (_objectTypeRepository.Valid) { result = new NewObjectTypeCommandResult(400, new Notification("Name", "Already in Use")); } } else { result = new NewObjectTypeCommandResult(400, objectType.Notifications); } } catch (Exception e) { _loggingService.Log(this.GetType(), ELogType.Neutral, ELogLevel.Error, new { command.Name, command.RequestHost }, e); } return(result); }