using System; using System.Collections.Generic; using System.Data.Entity; using System.Linq; using EnVisage.Models; namespace EnVisage.Code.BLL { public class UOMManager : ManagerBase { public UOMManager() : base(null) { } public UOMManager(EnVisageEntities dbContext) : base(dbContext) { } protected override UOM InitInstance() { return new UOM { Id = Guid.NewGuid() }; } protected override UOM RetrieveReadOnlyById(Guid key) { return DataTable.AsNoTracking().FirstOrDefault(t => t.Id == key); } public override DbSet DataTable => DbContext.UOMs; public Dictionary GetAsDictionary() { return DbContext.UOMs.AsNoTracking().ToDictionary(k => k.Id, v => v); } public Dictionary GetUOMsByExpenditureCategory() { return DbContext.ExpenditureCategory.AsNoTracking().Include(t => t.UOM).ToDictionary(k => k.Id, v => v.UOM.UOMValue); } } }