using EnertechWebAPI.Interfaces; using EnertechWebAPI.Responses; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; namespace EnertechWebAPI.Controllers { [Route("api/[controller]")] [ApiController] public class CommunityController : ControllerBase { private readonly ICommunityService communityService; public CommunityController(ICommunityService communityService) { this.communityService = communityService; } [HttpGet] public async Task Get() { var getCommunityResponse = await communityService.GetCommunity(); if (!getCommunityResponse.Success) { return UnprocessableEntity(getCommunityResponse); } var communityResponse = getCommunityResponse.Communities.ConvertAll(o => new CommunityResponse { CommunityId = o.CommunityId, CommunityName = o.CommunityName, CommunityPassword = o.CommunityPassword, CommunityUsername = o.CommunityUsername }); return Ok(communityResponse); } } }