public static IList <DTO.Goods> ToDTOs(this IList <Models.Good> models) { Mapper.Initialize(p => p.CreateMap <Models.GoodsDetail, DTO.GoodsDetail>()); List <DTO.Goods> list = new List <DTO.Goods>(); foreach (var item in models) { var goods = new DTO.Goods { id = item.id, name = item.name, detailName = item.detailName, unit = item.Unit1.unit1, category = item.Category1.category1, price = item.price, sellCount = item.sellCount, limited = item.limited, imageName = item.imageName, goodsStatus = item.goodsStatus, evaluate = item.evaluate, goodsDetail = null }; goods.goodsDetail = item.GoodsDetail.ToDTO(); list.Add(goods); } return(list); }
public static DTO.Goods ToDTO(this Models.Good model) { var goods = new DTO.Goods { id = model.id, name = model.name, detailName = model.detailName, unit = model.Unit1.unit1, category = model.Category1.category1, price = model.price, sellCount = model.sellCount, limited = model.limited, imageName = model.imageName, goodsStatus = model.goodsStatus, evaluate = model.evaluate, goodsDetail = null }; goods.goodsDetail = model.GoodsDetail.ToDTO(); return(goods); }
public static Models.Good ToModel(this DTO.Goods DTOObject) { return(DTOObject.ParseObject <DTO.Goods, Models.Good>()); }