4using Microsoft.EntityFrameworkCore;
29 .Include(ae => ae.Agreement)
30 .ThenInclude(a => a.Currency)
31 .Include(ae => ae.ModuleLevel)
57 if (agreementElement.
DateFrom !=
null && agreementElement.
DateTo !=
null)
59 throw new InvalidOperationException(
"DateFrom is not before DateTo.");
65 await
_db.SaveChangesAsync();
66 var returned = res.Entity;
85 if (agreementElement.
DateFrom !=
null && agreementElement.
DateTo !=
null)
87 throw new InvalidOperationException(
"DateFrom is not before DateTo.");
90 await
_db.SaveChangesAsync();
103 if (agreementElement ==
null)
104 throw new NullReferenceException($
"AgreementElement with id {id} doesn't exist.");
105 agreementElement.IsActive =
false;
119 if (agreementElement ==
null)
120 throw new NullReferenceException($
"AgreementElement with id {id} doesn't exist.");
121 agreementElement.IsActive =
true;
DbSet< ModuleLevel > ModuleLevels
DbSet< Agreement > Agreements
DbSet< AgreementElement > AgreementElements
DateTime? AgreementElementUpdated
AgreementElementService class inserts and updates AgreementElement in the Database
async Task< AgreementElement > GetAgreementElementById(int id)
Read one AgreementElement with id from database
async Task< AgreementElement > AddAgreementElement(AgreementElement agreementElement)
Adds a AgreementElement to the database
async Task< AgreementElement > ActivateAgreementElement(int id)
Activates a AgreementElement by setting IsActive attribute to true
async Task< AgreementElement > DeactivateAgreementElement(int id)
Deactivates a AgreementElement by setting IsActive attribute to false
async Task< List< AgreementElement > > GetAllAgreementElements()
Read all AgreementElements from database
AgreementElementService(DataContext db)
async Task< AgreementElement > UpdateAgreementElement(AgreementElement agreementElement)
Updates changes on a AgreementElement in the database
static bool DateFromIsBeforeDateTo(DateTime dateFrom, DateTime dateTo)
Compares dateFrom and dateTo