/// <summary> /// 获取联系人 /// </summary> /// <returns></returns> public ExcutedResult GetContacts(ChainModel model) { var user = CurrentUser; var result = Repository.GetContacts(user.Id); return(ExcutedResult.SuccessResult(result)); }
protected virtual ChainModel Consume(ChainModel current) { var children = Memory.Where(potentialChild => potentialChild.ParentHash.Equals(current.Hash)).ToList(); for (int i = 0; i < children.Count; i++) { children[i] = Consume(children[i]); } if (children.Count > 0) { var properties = current.GetType().GetProperties().Where(property => property.PropertyType.IsGenericType && property.PropertyType.GetGenericTypeDefinition() == typeof(IEnumerable <>)); foreach (var property in properties) { var propertyType = property.PropertyType.GetGenericArguments()[0]; var propertyItems = typeof(Enumerable).GetMethod("Cast").MakeGenericMethod(propertyType).Invoke(null, new object[] { children.Where(child => child.GetType() == propertyType).ToList() }); if (propertyItems != null) { object instanceOfProperty = property.GetValue(current); Type typeofMainProperty = instanceOfProperty.GetType(); MethodInfo methodOfMainProperty = typeofMainProperty.GetMethod("AddRange"); methodOfMainProperty.Invoke(instanceOfProperty, new[] { propertyItems }); } } } return(current); }
public void Setup() { var level = LevelModelTest.CreateLevel("level_model_test_common.json"); var chain = new ChainModel(); chain.level = level; chain.pinElement = new PinElementSignal(); chain.unpinElement = new UnpinElementSignal(); this.chain = chain; }
public void should_build_from_model_builder() { var id = Guid.NewGuid(); var visualizer = new ChainModel(); MockFor <IChainVisualizerBuilder>() .Expect(b => b.VisualizerFor(id)) .Return(visualizer); ClassUnderTest .Execute(new ChainRequest { Id = id }) .ShouldEqual(visualizer); }
public ExcutedResult <List <GetTokenListResponse> > GetTokenList([FromBody] ChainModel model) { try { if (!ModelState.IsValid) { return(ExcutedResult <List <GetTokenListResponse> > .FailedResult(BusinessResultCode.ArgumentError, "参数错误或无效")); } var result = _tokensLogic.GetTokenList(model); return(ExcutedResult <List <GetTokenListResponse> > .SuccessResult(result)); } catch (BusinessException bex) { return(ExcutedResult <List <GetTokenListResponse> > .FailedResult(bex.ErrorCode, bex.Message)); } }
/// <summary> /// 获取合约列表 /// </summary> /// <returns></returns> public List <GetTokenListResponse> GetTokenList(ChainModel model) { if (string.IsNullOrEmpty(model.ChainCode)) { throw new BusinessException(BusinessResultCode.ArgumentError, "参数错误"); } var param = new TokenParam { ChainCode = model.ChainCode }; var list = Repository.QueryList(param).ToList(); if (CurrentUser.Id != Guid.Empty) { var favoriteParam = new UserFavoriteParam { UserId = CurrentUser.Id, ItemType = (int)EnumItemType.Token, RelatedIds = list.Select(p => p.Id).ToList() }; } var result = list.OrderByDescending(p => p.IsSystem).ThenByDescending(p => p.Order).Select(p => new GetTokenListResponse() { Name = p.Name, Symbol = p.Symbol, Issuer = p.Issuer, Contract = p.Contract, Logo = p.Logo.HasValue ? _filePreUrl + p.Logo.Value : "", IsSystem = p.IsSystem, DollarPrice = p.DollarPrice, FaceBookUrl = p.FaceBookUrl, IssueCost = p.IssueCost, IssueDate = p.IssueDate, IssueState = p.IssueState, RmbPrice = p.RmbPrice, TwitterUrl = p.TwitterUrl, WebSite = p.WebSite, WhitePaperUrl = p.WhitePaperUrl, Decimals = p.Precision, Precision = p.TransactionPrecision }).ToList(); return(result); }