Skip to content

Update: code style problems on Controller and Service classes #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ on:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
permissions:
contents: read
actions: read
checks: write
jobs:
Testing:
runs-on: ubuntu-latest
Expand All @@ -30,11 +34,27 @@ jobs:
- name: Run integration tests
if: success() || failure()
run: dotnet test --no-build --verbosity normal --logger 'junit' --results-directory './.test-results/integration' ./tests/Integration/Integration.csproj;
- name: Publish artifacts
- name: Create Code Style Report
if: success() || failure()
uses: x-coders-team/dotnet-format-results@beta
id: code-style-html-report
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
json-results: '[]'
runner-workdir: ${{ github.workspace }}
- name: Publish artifacts generated by tests
uses: actions/upload-artifact@v3
if: success() || failure()
with:
name: test-results
path: |
.test-results/unit/TestResults.xml
.test-results/integration/TestResults.xml
.test-results/integration/TestResults.xml
- name: Publish artifacts generated by code style checks
uses: actions/upload-artifact@v3
if: success() || failure()
with:
name: code-style-checks-results
path: |
.linter-results/dotnet/
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ namespace CrontabRegistry.Application.Controllers
{
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private readonly ILogger<WeatherForecastController> _logger;
public class WeatherForecastController : ControllerBase{
private readonly ILogger<WeatherForecastController> _logger ;
private readonly IWeatherForecastService _weatherForecastService;

public WeatherForecastController(
Expand All @@ -17,13 +16,11 @@ IWeatherForecastService weatherForecastService
)
{
_logger = logger;
_weatherForecastService = weatherForecastService;
}

_weatherForecastService = weatherForecastService;}
[HttpGet(Name = "GetWeatherForecast")]
public async Task<IEnumerable<WeatherForecastModel>> Get()
{
public async Task <IEnumerable<WeatherForecastModel>>Get (){
return await _weatherForecastService.GenerateWeatherForecast();
}
}
}
}

21 changes: 11 additions & 10 deletions src/CrontabRegistry/Application/Services/WeatherForecastService.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using CrontabRegistry.Domain.Models;
using CrontabRegistry.Domain.Repositories;
using CrontabRegistry.Domain.Services;
using CrontabRegistry.Domain.Services;using CrontabRegistry.Domain.Repositories;

namespace CrontabRegistry.Application.Services
{


namespace CrontabRegistry.Application.Services{
public class WeatherForecastService : IWeatherForecastService
{
private readonly IWeatherForecastRepository _weatherForecastRepository;
Expand All @@ -15,16 +15,17 @@ IWeatherForecastRepository weatherForecastRepository
_weatherForecastRepository = weatherForecastRepository;
}

public async Task<IEnumerable<WeatherForecastModel>> GenerateWeatherForecast()
{
public async Task<IEnumerable<WeatherForecastModel>> GenerateWeatherForecast(){
var summaries = await _weatherForecastRepository.GetSummaries();

return Enumerable.Range(1, 5).Select(index => new WeatherForecastModel
{
return Enumerable.Range(1, 5).Select(index => new WeatherForecastModel {
Date = DateTime.Now.AddDays(index),
TemperatureC = Random.Shared.Next(-20, 55),
Summary = summaries[Random.Shared.Next(summaries.Length)]
}).ToArray();
}
}).ToArray();}
}




}