aboutsummaryrefslogtreecommitdiff
path: root/src/Web/DevHive.Web/Controllers/RatingController.cs
diff options
context:
space:
mode:
authortranstrike <transtrike@gmail.com>2021-03-15 09:27:12 +0200
committertranstrike <transtrike@gmail.com>2021-03-15 09:27:12 +0200
commit0161be09312fde634865f110504884119a617d5c (patch)
tree0fa68366edcb024c054f370ecf90f5b66282aae5 /src/Web/DevHive.Web/Controllers/RatingController.cs
parente3b5757b5a5db2f7874b0924cdd4a22b1a9e1ee2 (diff)
parentac82c773a5ec43c6a59d3d0b7665b67ac9e6bdde (diff)
downloadDevHive-0161be09312fde634865f110504884119a617d5c.tar
DevHive-0161be09312fde634865f110504884119a617d5c.tar.gz
DevHive-0161be09312fde634865f110504884119a617d5c.zip
Fixed to new() where possible and readable
Diffstat (limited to 'src/Web/DevHive.Web/Controllers/RatingController.cs')
-rw-r--r--src/Web/DevHive.Web/Controllers/RatingController.cs13
1 files changed, 6 insertions, 7 deletions
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();