EnVisageOnline/Main/Source/EnVisage/Code/BLL/UOMManager.cs

42 lines
1.1 KiB
C#

using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using EnVisage.Models;
namespace EnVisage.Code.BLL
{
public class UOMManager : ManagerBase<UOM, UOMModel>
{
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<UOM> DataTable => DbContext.UOMs;
public Dictionary<Guid, UOM> GetAsDictionary()
{
return DbContext.UOMs.AsNoTracking().ToDictionary(k => k.Id, v => v);
}
public Dictionary<Guid, decimal> GetUOMsByExpenditureCategory()
{
return DbContext.ExpenditureCategory.AsNoTracking().Include(t => t.UOM).ToDictionary(k => k.Id, v => v.UOM.UOMValue);
}
}
}