Skip to content

Commit

Permalink
Merge pull request #141 from dotnetgoo/Nozimjon
Browse files Browse the repository at this point in the history
GroupAssetService added
  • Loading branch information
Nozimjon04 authored Nov 4, 2023
2 parents 448560c + 766a68f commit e4b2c2f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -13,9 +14,9 @@ public GroupAssetsController(IGroupAssetService groupAssetService)
_groupAssetService = groupAssetService;
}

[HttpPost]
public async Task<IActionResult> PostAsync(IFormFile formFile)
=> Ok(await _groupAssetService.CreateAsync(formFile));
[HttpPost("{group-id}")]
public async Task<IActionResult> PostAsync([FromRoute(Name = "group-id")] long groupId, [Required] IFormFile formFile)
=> Ok(await _groupAssetService.CreateAsync(groupId,formFile));

[HttpGet("{group-id}")]
public async Task<IActionResult> GetAllAsync([FromQuery] PaginationParams @params, [FromRoute(Name = "groupId")] long groupId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Shamsheer.Service.Interfaces.GroupAssets;
public interface IGroupAssetService
{
Task<bool> RemoveAsync(long groupId, long id);
Task<GroupAssetForResultDto> CreateAsync(IFormFile formFile);
Task<GroupAssetForResultDto> CreateAsync(long groupId, IFormFile formFile);
Task<GroupAssetForResultDto> RetrieveByIdAsync(long groupId, long id);
Task<IEnumerable<GroupAssetForResultDto>> RetrieveAllAsync(long groupId, PaginationParams @params);
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@ public GroupAssetService(IMapper mapper, IGroupRepository groupRepository, IGrou
_groupRepository = groupRepository;
_groupAssetRepository = groupAssetRepository;
}
public async Task<GroupAssetForResultDto> CreateAsync(IFormFile formFile)
public async Task<GroupAssetForResultDto> 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();
Expand Down

0 comments on commit e4b2c2f

Please sign in to comment.