diff --git a/src/Shamsheer.Messenger.Api/Controllers/GroupAssets/GroupAssetsController.cs b/src/Shamsheer.Messenger.Api/Controllers/GroupAssets/GroupAssetsController.cs index 807fc9c..466b1db 100644 --- a/src/Shamsheer.Messenger.Api/Controllers/GroupAssets/GroupAssetsController.cs +++ b/src/Shamsheer.Messenger.Api/Controllers/GroupAssets/GroupAssetsController.cs @@ -1,6 +1,7 @@ using Microsoft.AspNetCore.Mvc; using Shamsheer.Service.Configurations; using Shamsheer.Service.Interfaces.GroupAssets; +using System.ComponentModel.DataAnnotations; namespace Shamsheer.Messenger.Api.Controllers.GroupAssets; @@ -13,9 +14,9 @@ public GroupAssetsController(IGroupAssetService groupAssetService) _groupAssetService = groupAssetService; } - [HttpPost] - public async Task PostAsync(IFormFile formFile) - => Ok(await _groupAssetService.CreateAsync(formFile)); + [HttpPost("{group-id}")] + public async Task PostAsync([FromRoute(Name = "group-id")] long groupId, [Required] IFormFile formFile) + => Ok(await _groupAssetService.CreateAsync(groupId,formFile)); [HttpGet("{group-id}")] public async Task GetAllAsync([FromQuery] PaginationParams @params, [FromRoute(Name = "groupId")] long groupId) diff --git a/src/Shamsheer.Service/Interfaces/GroupAssets/IGroupAssetService.cs b/src/Shamsheer.Service/Interfaces/GroupAssets/IGroupAssetService.cs index ab623f1..5a027af 100644 --- a/src/Shamsheer.Service/Interfaces/GroupAssets/IGroupAssetService.cs +++ b/src/Shamsheer.Service/Interfaces/GroupAssets/IGroupAssetService.cs @@ -9,7 +9,7 @@ namespace Shamsheer.Service.Interfaces.GroupAssets; public interface IGroupAssetService { Task RemoveAsync(long groupId, long id); - Task CreateAsync(IFormFile formFile); + Task CreateAsync(long groupId, IFormFile formFile); Task RetrieveByIdAsync(long groupId, long id); Task> RetrieveAllAsync(long groupId, PaginationParams @params); } \ No newline at end of file diff --git a/src/Shamsheer.Service/Services/GroupAssets/GroupAssetService.cs b/src/Shamsheer.Service/Services/GroupAssets/GroupAssetService.cs index c387bae..09b6063 100644 --- a/src/Shamsheer.Service/Services/GroupAssets/GroupAssetService.cs +++ b/src/Shamsheer.Service/Services/GroupAssets/GroupAssetService.cs @@ -29,10 +29,8 @@ public GroupAssetService(IMapper mapper, IGroupRepository groupRepository, IGrou _groupRepository = groupRepository; _groupAssetRepository = groupAssetRepository; } - public async Task CreateAsync(IFormFile formFile) + public async Task CreateAsync(long groupId, IFormFile formFile) { - //Identify GroupId TODO:LOGIC - long groupId = 1; //Actually this one is takes from jwt token, now we need to give default value var group = await _groupRepository.SelectAll() .Where(g => g.Id == groupId) .FirstOrDefaultAsync();