public async Task <ActionResult <GoalViewModel> > PutWeek(Guid id, [FromBody] GoalViewModel goalViewModel) { if (id != goalViewModel.Id) { return(BadRequest()); } var goalYearPrevious = await _goalWeekService.Update(goalViewModel.ToWeekDb()); return(goalYearPrevious.ToViewModel()); }
public async Task <ActionResult <GoalViewModel> > PostWeek([FromBody] GoalViewModel goalViewModel) { var userGuid = GetUserId(); if (!userGuid.HasValue) { return(Forbid()); } goalViewModel.OwnerId = userGuid.Value; var entry = await _goalWeekService.Add(goalViewModel.ToWeekDb()); return(CreatedAtAction(nameof(GetByIdYear), new { id = entry.Id }, entry)); }