40 lines
966 B
C#
40 lines
966 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data.Entity;
|
|
using System.Linq;
|
|
using System.Web.Mvc;
|
|
using EnVisage.Models;
|
|
|
|
namespace EnVisage.Code.BLL
|
|
{
|
|
public class ExpenditureManager : ManagerBase<Expenditure, ExpenditureModel>
|
|
{
|
|
public ExpenditureManager(EnVisageEntities dbContext)
|
|
: base(dbContext)
|
|
{
|
|
}
|
|
|
|
protected override Expenditure InitInstance()
|
|
{
|
|
return new Expenditure { Id = Guid.NewGuid() };
|
|
}
|
|
|
|
protected override Expenditure RetrieveReadOnlyById(Guid key)
|
|
{
|
|
return DataTable.AsNoTracking().FirstOrDefault(t => t.Id == key);
|
|
}
|
|
|
|
public override DbSet<Expenditure> DataTable => DbContext.Expenditures;
|
|
|
|
public IEnumerable<SelectListItem> GetExpenditures()
|
|
{
|
|
return DataTable.AsNoTracking()
|
|
.OrderBy(e => e.Name)
|
|
.Select(e => new SelectListItem
|
|
{
|
|
Value = e.Id.ToString(),
|
|
Text = e.Name
|
|
}).ToList();
|
|
}
|
|
}
|
|
} |