Academatica.Api/Academatica.Api.Users/Controllers/UsersController.cs
/// <summary>
/// Endpoint used to decrease the amount of lifebuoys user has.
/// </summary>
/// <param name="id">User ID.</param>
Endpoint used to decrease the amount of lifebuoys user has.
Endpoint used to decrease the amount of lifebuoys user has .
[HttpPatch]
        [Route("{id}/buoys")]
        public async Task<IActionResult> DecreaseUserBuoys(Guid id)
        {
            var userStats = _academaticaDbContext.UserStats.Where(x => x.UserId == id).FirstOrDefault();
            if (userStats == null)
            {
                return NotFound("Stats entry could not be found.");
            }
            userStats.BuoysLeft -= userStats.BuoysLeft == 0 ? 0u : 1u;
            await _academaticaDbContext.SaveChangesAsync();
            return Ok();
        }
[ HttpPatch ] [ Route ( " " ) ] public async Task < IActionResult > DecreaseUserBuoys ( Guid id ) { var userStats = _academaticaDbContext . UserStats . Where ( x => x . UserId == id ) . FirstOrDefault ( ) ; if ( userStats == null ) { return NotFound ( " " ) ; } userStats . BuoysLeft -= userStats . BuoysLeft == 0 ? 0u : 1u ; await _academaticaDbContext . SaveChangesAsync ( ) ; return Ok ( ) ; }
Endpoint used to decrease the amount of lifebuoys user has.
Endpoint used to decrease the amount of lifebuoys user has .
id
Guid
None