Esempio n. 1
0
        public ExerciseModel CreateViewModel(Exercise datamodel)
        {
            if (datamodel == null)
            {
                throw new ArgumentNullException("datamodel");
            }
            var result = new ExerciseModel()
            {
                Id          = datamodel.Id,
                Description = datamodel.Description,
                Name        = datamodel.Name,
                Url         = _UrlHelper.Link("GetExerciseById", new { id = datamodel.Id })
            };

            if (datamodel.Schedules != null && datamodel.Schedules.Any())
            {
                result.Schedules = datamodel.Schedules.Select(x => new EntryModel <int>()
                {
                    Id   = x.Id,
                    Name = x.Name,
                    Url  = _UrlHelper.Link("GetScheduleById", new { id = x.Id })
                });
            }
            return(result);
        }
Esempio n. 2
0
        public Exercise CreateModel(ExerciseModel model, Exercise datamodel = null)
        {
            var result = datamodel ?? new Exercise();

            result.Description = model.Description;
            result.Name        = model.Name;
            result.Id          = model.Id;
            return(result);
        }