private static void DefineJobToJobModelWithFilterMapping() { MapperObject.AddMap <Job, JobModel>(src => { var res = new JobModel(); res.InjectFrom <IgnoreProps>(src); if (!string.IsNullOrEmpty(src.Name)) { res.Name = "[ " + src.Name + " ]"; } if (src.Materials != null && src.Materials.Count > 0) { res.Materials = src.Materials.Select(x => MapperObject.Map <Material, MaterialModel>(x)).ToList(); } return(res); }); }
private static void DefineJobToJobModelMapping() { MapperObject.AddMap <Job, JobModel>(src => { var res = new JobModel(); res.InjectFrom(src); res.TenantDomain = src.DomainId; if (!string.IsNullOrEmpty(src.Name)) { res.Name = "[ " + src.Name + " ]"; } else { res.Name = string.Empty; } if (src.Materials != null && src.Materials.Count > 0) { res.Materials = src.Materials.Select(x => MapperObject.Map <Material, MaterialModel>(x)).ToList(); } if (src.ToolRelationships != null) { var tools = from j in src.ToolRelationships where j.JobId == src.JobId select new Tool() { ToolId = j.ToolId }; res.Tools = tools.Select(x => MapperObject.Map <Tool, ToolModel>(x)).ToList(); } if (src.AccessoryRelationships != null) { var accessories = from j in src.AccessoryRelationships where j.JobId == src.JobId select new Accessory() { AccessoryId = j.AccessoryId }; res.Accessories = accessories.Select(x => MapperObject.Map <Accessory, AccessoryModel>(x)).ToList(); } return(res); }); }