aboutsummaryrefslogtreecommitdiff
path: root/src/Web/DevHive.Web
diff options
context:
space:
mode:
Diffstat (limited to 'src/Web/DevHive.Web')
-rw-r--r--src/Web/DevHive.Web/Configurations/Mapping/RatingMappings.cs2
-rw-r--r--src/Web/DevHive.Web/Controllers/RatingController.cs13
-rw-r--r--src/Web/DevHive.Web/Startup.cs1
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
{