diff options
| author | Danail Dimitrov <danaildimitrov321@gmail.com> | 2021-03-14 21:40:12 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-14 21:40:12 +0200 |
| commit | ac82c773a5ec43c6a59d3d0b7665b67ac9e6bdde (patch) | |
| tree | 8d57d347dd56642105998c3cc3d12bd16ac49aa1 /src/Web/DevHive.Web | |
| parent | 432fc5890814596d50fb409a6e5dc952d7bb4836 (diff) | |
| parent | 76f71bb8cab45922f3e4999253a1567a0e4af3db (diff) | |
| download | DevHive-ac82c773a5ec43c6a59d3d0b7665b67ac9e6bdde.tar DevHive-ac82c773a5ec43c6a59d3d0b7665b67ac9e6bdde.tar.gz DevHive-ac82c773a5ec43c6a59d3d0b7665b67ac9e6bdde.zip | |
Merge pull request #22 from Team-Kaleidoscope/rating_system
Rating system
Diffstat (limited to 'src/Web/DevHive.Web')
| -rw-r--r-- | src/Web/DevHive.Web/Configurations/Mapping/RatingMappings.cs | 2 | ||||
| -rw-r--r-- | src/Web/DevHive.Web/Controllers/RatingController.cs | 13 | ||||
| -rw-r--r-- | src/Web/DevHive.Web/Startup.cs | 1 |
3 files changed, 7 insertions, 9 deletions
diff --git a/src/Web/DevHive.Web/Configurations/Mapping/RatingMappings.cs b/src/Web/DevHive.Web/Configurations/Mapping/RatingMappings.cs index 23c3eeb..1d731d8 100644 --- a/src/Web/DevHive.Web/Configurations/Mapping/RatingMappings.cs +++ b/src/Web/DevHive.Web/Configurations/Mapping/RatingMappings.cs @@ -1,5 +1,5 @@ using AutoMapper; -using DevHive.Services.Models.Post.Rating; +using DevHive.Services.Models.Rating; using DevHive.Web.Models.Rating; namespace DevHive.Web.Configurations.Mapping diff --git a/src/Web/DevHive.Web/Controllers/RatingController.cs b/src/Web/DevHive.Web/Controllers/RatingController.cs index 5716b85..7d21795 100644 --- a/src/Web/DevHive.Web/Controllers/RatingController.cs +++ b/src/Web/DevHive.Web/Controllers/RatingController.cs @@ -3,7 +3,7 @@ using System.Threading.Tasks; using AutoMapper; using DevHive.Common.Jwt.Interfaces; using DevHive.Services.Interfaces; -using DevHive.Services.Models.Post.Rating; +using DevHive.Services.Models.Rating; using DevHive.Web.Models.Rating; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; @@ -11,19 +11,17 @@ using Microsoft.AspNetCore.Mvc; namespace DevHive.Web.Controllers { [ApiController] - //[Authorize(Roles = "Admin,User")] + [Authorize(Roles = "Admin,User")] [Route("api/[controller]")] public class RatingController { private readonly IRatingService _rateService; - private readonly IUserService _userService; private readonly IMapper _mapper; private readonly IJwtService _jwtService; - public RatingController(IRatingService rateService, IUserService userService, IMapper mapper, IJwtService jwtService) + public RatingController(IRatingService rateService, IMapper mapper, IJwtService jwtService) { this._rateService = rateService; - this._userService = userService; this._mapper = mapper; this._jwtService = jwtService; } @@ -65,7 +63,7 @@ namespace DevHive.Web.Controllers } [HttpPut] - public async Task<IActionResult> UpdateRating(Guid userId, [FromBody] UpdateRatingWebModel updateRatingWebModel, [FromHeader] string authorization) + public async Task<IActionResult> UpdateRating(Guid userId, Guid postId, [FromBody] UpdateRatingWebModel updateRatingWebModel, [FromHeader] string authorization) { if (!this._jwtService.ValidateToken(userId, authorization)) return new UnauthorizedResult(); @@ -73,6 +71,7 @@ namespace DevHive.Web.Controllers UpdateRatingServiceModel updateRatingServiceModel = this._mapper.Map<UpdateRatingServiceModel>(updateRatingWebModel); updateRatingServiceModel.UserId = userId; + updateRatingServiceModel.PostId = postId; ReadRatingServiceModel readRatingServiceModel = await this._rateService.UpdateRating(updateRatingServiceModel); @@ -86,7 +85,7 @@ namespace DevHive.Web.Controllers } [HttpDelete] - public async Task<IActionResult> DeleteTating(Guid userId, Guid ratingId, [FromHeader] string authorization) + public async Task<IActionResult> DeleteRating(Guid userId, Guid ratingId, [FromHeader] string authorization) { if (!this._jwtService.ValidateToken(userId, authorization)) return new UnauthorizedResult(); diff --git a/src/Web/DevHive.Web/Startup.cs b/src/Web/DevHive.Web/Startup.cs index ebd091e..002c718 100644 --- a/src/Web/DevHive.Web/Startup.cs +++ b/src/Web/DevHive.Web/Startup.cs @@ -5,7 +5,6 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using DevHive.Web.Configurations.Extensions; using Newtonsoft.Json; -using System.Threading.Tasks; namespace DevHive.Web { |
