Пример #1
0
        public static BodyPartsViewModel CreateBPartViewModel(this IBodyPartRepository bPart, IBodyAreaRepository bodyArea, int?Id, DBGetter db)
        {
            BodyPart           bodyPart = bPart.GetBodyPartById(Id);
            BodyPartsViewModel bPartVM  = new BodyPartsViewModel()
            {
                Name        = bodyPart.Name,
                BodyAreaId  = bodyPart.BodyAreaId,
                Description = bodyPart.Description,
                Image       = bodyPart.Image,
                BodyPartId  = bodyPart.BodyPartId,
                BodyAreas   = bodyArea.BodyAreas.ToList(),
                Muscles     = bodyPart.GetListMuscleVM(db)
            };

            return(bPartVM);
        }
Пример #2
0
        public static ICollection <MuscleViewModel> GetListMuscleVM(this BodyPartsViewModel bPartVM, DBGetter db)
        {
            List <MuscleViewModel> muscles = new List <MuscleViewModel>();

            foreach (var muscle in db.muscles)
            {
                if (muscle.BodyPartId == bPartVM.BodyPartId)
                {
                    muscles.Add(new MuscleViewModel()
                    {
                        BodyPartId  = muscle.BodyPartId,
                        Description = muscle.Description,
                        Image       = muscle.Image,
                        MuscleId    = muscle.MuscleId,
                        Name        = muscle.Name,
                        BodyParts   = db.bodyParts.ToList()
                    });
                }
            }

            return(muscles);
        }