Last active
December 28, 2021 19:36
-
-
Save domingoladron/7971b23bebcba9910c9f648b5e6f9c5f to your computer and use it in GitHub Desktop.
DDD-ApplicationService-Encapsulation.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Threading.Tasks; | |
using EncapsulationApi.DDD.DomainModels; | |
using EncapsulationApi.DDD.Repositories; | |
namespace EncapsulationApi.DDD.ApplicationServices | |
{ | |
public class DomainModelApplicationService : IDomainModelApplicationService | |
{ | |
private readonly IDomainModelRepository _domainModelRepository; | |
public DomainModelApplicationService( | |
IDomainModelRepository domainModelRepository) | |
{ | |
_domainModelRepository = domainModelRepository; | |
} | |
/// <summary> | |
/// A simple method on our Application Service which knows nothing about | |
/// how the work is done, but simply what to call when to get the work completed. | |
/// </summary> | |
public async Task SubmitDraft() | |
{ | |
var domainModel = await _domainModelRepository.GetDomainModel(); | |
domainModel.ChangeState(DomainModelState.Submitted); | |
await _domainModelRepository.SaveDomainModel(domainModel); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment