Exemplo n.º 1
0
        public async Task <IActionResult> Points(Guid userId, [FromBody] PointsUpdateModel model)
        {
            var response = await _service.UpdatePointsAsync(userId, model);

            if (!response.IsSuccessful)
            {
                return(ProcessResponse(response));
            }

            await _service.SaveChangesAsync();

            return(ProcessResponse(response));
        }
Exemplo n.º 2
0
        public async Task <IResponse> UpdatePointsAsync(Guid userId, PointsUpdateModel model)
        {
            if (userId == default)
            {
                return(new Response(HttpStatusCode.BadRequest, false, $"Invalid user"));
            }

            var user = await _repository.GetByIdAsync(userId);

            user.Points = model.Points;
            await _repository.SaveAsync(user);

            return(new Response(HttpStatusCode.OK, true));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Points(Guid userId, [FromBody] PointsUpdateModel model)
        {
            await _usersService.Points(userId, model);

            return(Ok());
        }