public async Task<IHttpActionResult> PutExcerciseList(int id, ExcerciseList excerciseList) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != excerciseList.Id) { return BadRequest(); } _ctx.Entry(excerciseList).State = EntityState.Modified; try { await _ctx.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ExcerciseListExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostExcerciseList(ExcerciseList excerciseList) { if (!ModelState.IsValid) { return BadRequest(ModelState); } _ctx.ExcerciseList.Add(excerciseList); await _ctx.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = excerciseList.Id }, excerciseList); }
public void ExcerciseAdd(Activity act, DateTime begin, DateTime end) { var activity = ActivitiList.SingleOrDefault(a => a.Name == act.Name); if (activity == null) { ActivitiList.Add(act); var excercise = new Excercise(CurrUser, begin, end, act); ExcerciseList.Add(excercise); } else { var excercise = new Excercise(CurrUser, begin, end, activity); ExcerciseList.Add(excercise); } SaveData(); }