public Practice CreateModel(PracticeModel model, Practice datamodel = null) { var result = datamodel ?? new Practice(); result.Timestamp = model.Timestamp; result.Repetitions = model.Repetitions; result.ExerciseId = model.ExerciseId; result.ScheduleId = model.ScheduleId; result.UserId = model.UserId; result.Weight = model.Weight; result.NumberOfRepetitions = model.NumberOfRepetitions; result.Id = model.Id; return(result); }
public async Task<IHttpActionResult> CreatePractice(PracticeModel practice) { if (!ModelState.IsValid) { return BadRequest(ModelState); } var datamodel = this.TheModelFactory.CreateModel(practice); await this.AppRepository.Practices.AddAsync(datamodel); practice = this.TheModelFactory.CreateViewModel(datamodel); return CreatedAtRoute("GetPracticeById", new { id = practice.Id }, practice); }
public Practice CreateModel(PracticeModel model, Practice datamodel = null) { var result = datamodel ?? new Practice(); result.Timestamp = model.Timestamp; result.Repetitions = model.Repetitions; result.ExerciseId = model.ExerciseId; result.ScheduleId = model.ScheduleId; result.UserId = model.UserId; result.Weight = model.Weight; result.NumberOfRepetitions = model.NumberOfRepetitions; result.Id = model.Id; return result; }