Exemplo n.º 1
0
        public async Task <ActionResult <GoalViewModel> > PutDay(Guid id, [FromBody] GoalViewModel goalViewModel)
        {
            if (id != goalViewModel.Id)
            {
                return(BadRequest());
            }

            var goalYearPrevious = await _goalDayService.Update(goalViewModel.ToDayDb());

            return(goalYearPrevious.ToViewModel());
        }
Exemplo n.º 2
0
        public async Task <ActionResult <GoalViewModel> > PostDay([FromBody] GoalViewModel goalViewModel)
        {
            var userGuid = GetUserId();

            if (!userGuid.HasValue)
            {
                return(Forbid());
            }

            goalViewModel.OwnerId = userGuid.Value;

            var entry = await _goalDayService.Add(goalViewModel.ToDayDb());

            return(CreatedAtAction(nameof(GetByIdYear), new { id = entry.Id }, entry));
        }