Beispiel #1
0
        public async Task <IActionResult> PutAsync(Guid id, [FromBody] RoundInputModel model)
        {
            if (default(Guid).Equals(id))
            {
                AddNotification("O Id da rodada não foi informado.");
                return(ResponseInvalid());
            }

            if (ModelState.IsValid)
            {
                var round = new Round(model.Description, model.Date, model.RankingId);
                await _roundService.UpdateAsync(id, round);

                if (ValidOperation())
                {
                    return(NoContent());
                }

                return(ResponseInvalid());
            }

            NotifyModelStateError();

            return(ResponseInvalid());
        }
Beispiel #2
0
        public async Task <IActionResult> PostAsync([FromBody] RoundInputModel model)
        {
            if (ModelState.IsValid)
            {
                var round = new Round(model.Description, model.Date, model.RankingId);
                await _roundService.AddAsync(round);

                if (ValidOperation())
                {
                    return(Created(GetRouteById(round.Id), new { id = round.Id }));
                }

                return(ResponseInvalid());
            }

            NotifyModelStateError();

            return(ResponseInvalid());
        }