public async Task <ActionResult> Put(Guid id, [FromBody] BloodPressureReadingInput bloodPressureReadingInput) { var bloodPressureReadingToEdit = new BloodPressureReading(id, bloodPressureReadingInput.Systole, bloodPressureReadingInput.Diastole, bloodPressureReadingInput.HeartRate); bloodPressureReadingToEdit.DateTaken = bloodPressureReadingInput.DateTaken; bloodPressureReadingToEdit.PersonId = _contextData.CurrentUser.Id; _healthWiseDbContext.Attach <BloodPressureReading>(bloodPressureReadingToEdit).State = EntityState.Modified; await _healthWiseDbContext.SaveChangesAsync(); return(NoContent()); }
public async Task <ActionResult> Post([FromBody] BloodPressureReadingInput bloodPressureReadingInput) { var bloodPressureReadingToCreate = new BloodPressureReading(bloodPressureReadingInput.Systole, bloodPressureReadingInput.Diastole, bloodPressureReadingInput.HeartRate); bloodPressureReadingToCreate.DateTaken = bloodPressureReadingInput.DateTaken; bloodPressureReadingToCreate.PersonId = _contextData.CurrentUser.Id; await _healthWiseDbContext.BloodPressureReadings.AddAsync(bloodPressureReadingToCreate); await _healthWiseDbContext.SaveChangesAsync(); return(CreatedAtAction(nameof(this.Get), new { id = bloodPressureReadingToCreate.Id }, BloodPressureReadingDto.Create(bloodPressureReadingToCreate))); }