< Summary

Information
Class: LifeChart.Application.UseCases.Entries.SaveDailyEntryUseCase
Assembly: LifeChart.Application
File(s): /home/runner/work/lifechart/lifechart/src/LifeChart.Application/UseCases/Entries/SaveDailyEntryUseCase.cs
Tag: 113_29159449707
Line coverage
100%
Covered lines: 20
Uncovered lines: 0
Coverable lines: 20
Total lines: 38
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
get_IsCritical()100%11100%
ExecuteAsync()100%11100%

File(s)

/home/runner/work/lifechart/lifechart/src/LifeChart.Application/UseCases/Entries/SaveDailyEntryUseCase.cs

#LineLine coverage
 1using LifeChart.Application.DTOs;
 2using LifeChart.Domain.Entries;
 3using LifeChart.Domain.Services;
 4
 5namespace LifeChart.Application.UseCases.Entries;
 6
 7public class SaveDailyEntryUseCase
 8{
 9    private readonly IDailyEntryRepository _repository;
 10    private readonly CrisisThresholdService _crisisService;
 11
 912    public SaveDailyEntryUseCase(
 913        IDailyEntryRepository repository,
 914        CrisisThresholdService crisisService)
 15    {
 916        _repository = repository;
 917        _crisisService = crisisService;
 918    }
 19
 1520    public record Result(bool IsCritical);
 21
 22    public async Task<Result> ExecuteAsync(DailyEntryDto dto)
 23    {
 924        var entry = new DailyEntry(
 925            dto.Date,
 926            new MoodScore(dto.Mood),
 927            new FunctionalityScore(dto.Functionality),
 928            new SleepHours(dto.SleepHours),
 929            dto.MedicationTaken,
 930            dto.MenstrualCycle,
 931            dto.Symptoms,
 932            dto.Notes,
 933            dto.IsHypomanic);
 34
 835        await _repository.SaveAsync(entry);
 836        return new Result(_crisisService.IsCritical(entry));
 837    }
 38}