예제 #1
0
        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());
        }
예제 #2
0
        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));
        }