3using Microsoft.EntityFrameworkCore;
52 throw new InvalidOperationException($
"Modulelevel with name {moduleLevel.ModuleLevelName} already exists.");
61 await
_db.SaveChangesAsync();
75 throw new InvalidOperationException($
"Modulelevel with name {moduleLevel.ModuleLevelName} already exists.");
84 await
_db.SaveChangesAsync();
97 if (moduleLevel ==
null)
throw new NullReferenceException($
"Module with id {id} doesn't exist.");
98 moduleLevel.IsActive =
false;
112 if (moduleLevel ==
null)
throw new NullReferenceException($
"Module with id {id} doesn't exist.");
113 moduleLevel.IsActive =
true;
DbSet< ModuleLevel > ModuleLevels
ModuleLevelService class inserts and updates ModuleLevel in the Database
async Task< ModuleLevel > GetModuleLevelById(int id)
Read one ModuleLevel with id from database
async Task< ModuleLevel > DeactivateModuleLevel(int id)
Activates a ModuleLevel by setting IsActive attribute to false
async Task< ModuleLevel > ActivateModuleLevel(int id)
Activates a ModuleLevel by setting IsActive attribute to false
ModuleLevelService(DataContext db)
async Task< ModuleLevel > UpdateModuleLevel(ModuleLevel moduleLevel)
Updates changes on a ModuleLevel in the database
async Task< ModuleLevel > AddModuleLevel(ModuleLevel moduleLevel)
Adds a ModuleLevel to the database
async Task< List< ModuleLevel > > GetAllModuleLevels()
Read all ModuleLevels from database