Beispiel #1
0
        public async Task<IActionResult> Update(
            [FromRoute] int coverId,
            [FromBody] UpdateLimitRequest updateLimitRequest)
        {
            var userOwnsPost = await _coverService.UserOwnsCover(coverId, HttpContext.GetUserId());

            if (userOwnsPost)
            {
                var limitFromDb = await _coverService.GetByIdAsync(coverId);
                limitFromDb.LimitMultiplier = updateLimitRequest.LimitMultiplier;

                var updated = await _coverService.UpdateAsync(limitFromDb);

                if (updated) return Ok(_mapper.Map<CoverResponse>(limitFromDb));
            }

            return BadRequest(new {error = "You do not own this cover !"});
        }