public static ViewClassReport ToViewModel(ClassReport model) { if (model == null) { return(null); } ViewClassReport item = new ViewClassReport(); item.Id = model.Id; item.Title = model.Title; item.Content = model.Content; item.UserId = model.UserId; item.ClassId = model.ClassId; item.IsDeleted = model.IsDeleted; item.CreateTime = model.CreateTime; List <ViewClassFile> files = (from f in model.ClassFile select ViewClassFile.ToViewModel(f)).ToList(); item.Images = new List <ViewClassFile>(); item.Videos = new List <ViewClassFile>(); foreach (var file in files) { if (file.Type == 11) { item.Images.Add(file); } else if (file.Type == 12) { item.Videos.Add(file); } } return(item); }
public static ViewClass ToViewModel(Class model) { if (model == null) { return(null); } ViewClass item = new ViewClass(); item.Id = model.Id; item.YogaTypeID = model.YogaTypeID; item.Summary = model.Summary; item.Content = model.Content; item.Banner = model.Banner; item.Start = model.Start; item.Duration = model.Duration; item.DurationUnit = model.DurationUnit; item.AreaID = model.AreaID; item.Address = model.Address; item.Price = model.Price; item.Discount = model.Discount; item.IsItem = model.IsItem; item.ItemClassID = model.ItemClassID; item.Max = model.Max; item.ClassType = model.ClassType; item.ClassStatus = model.ClassStatus; item.NoPassMsg = model.NoPassMsg; item.UserId = model.UserId; item.UpdateTime = model.UpdateTime; item.IsDeleted = model.IsDeleted; item.CreateTime = model.CreateTime; item.Name = model.Name; item.TopicIds = model.TopicIds; item.Tags = model.Tags; item.InterestCount = model.InterestedClass.Count; item.User = ViewYogaUser.ToViewModel(model.User); item.ReportCount = model.ClassReport.Count; item.Reports = (from r in model.ClassReport select ViewClassReport.ToViewModel(r)).ToList(); item.Teachers = (from r in model.ClassTeacher select ViewClassTeacher.ToViewModel(r)).ToList(); item.iShareNums = model.iShareNums; item.iReadNums = model.iReadNums; item.CloseTime = model.CloseTime; item.EndTime = model.EndTime; item.MessageDes = model.MessageDes; item.CenterID = model.CenterID; return(item); }
public static ClassReport ToEntity(ViewClassReport model) { ClassReport item = new ClassReport(); item.Id = model.Id; item.Title = model.Title; item.Content = model.Content; item.UserId = model.UserId; item.ClassId = model.ClassId; item.IsDeleted = model.IsDeleted; item.CreateTime = model.CreateTime; return(item); }