コード例 #1
0
ファイル: Mapper.cs プロジェクト: ttu/Match-Rate
        public static FightViewModel ConvertToViewModel(this Fight current, IRepository repo)
        {
            FightViewModel retVal = new FightViewModel(repo)
            {
                ID = current.ID, IpVote = current.IpVote, Up = current.Up, Down = current.Down
            };

            retVal.Fighter1 = current.Fighter1.ConvertToViewModel(repo);
            retVal.Fighter2 = current.Fighter2.ConvertToViewModel(repo);

            return(retVal);
        }
コード例 #2
0
ファイル: Mapper.cs プロジェクト: ttu/Match-Rate
        public static EventViewModel ConvertToViewModel(this Event current, IRepository repo)
        {
            EventViewModel retVal = new EventViewModel(repo)
            {
                ID = current.ID, Name = current.Name, Date = current.Date
            };

            if (current.Fights != null)
            {
                retVal.Fights = new System.Collections.Generic.List <FightViewModel>();

                foreach (Fight f in current.Fights)
                {
                    FightViewModel fight = f.ConvertToViewModel(repo);
                    retVal.Fights.Add(fight);
                }
            }

            return(retVal);
        }