public ActionResult ReadDatabase([DataSourceRequest] DataSourceRequest request) { List <Card> card = db.Set <Card>().ToList(); var result = card.Select(x => new CardViewModel { ID = x.ID, number = x.number, state = x.state, expirationDate = x.expirationDate }); return(Json(result.ToDataSourceResult(request))); }
public async Task Execute(IJobExecutionContext context) { CardContext db = new CardContext(); List <Card> cards = db.Set <Card>().Where(card => card.expirationDate <= DateTime.Now && card.state != State.Expired).ToList(); foreach (Card card in cards) { CardHistory cardHistory = new CardHistory(); card.state = State.Expired; cardHistory.acquisitionDate = DateTime.Now; cardHistory.stateChangeDate = DateTime.Now; cardHistory.card = card; db.CardHistories.Add(cardHistory); } db.SaveChanges(); }
public virtual async Task <TEntity> GetAsync(Guid id) { TEntity entity = await _context.Set <TEntity>().FirstOrDefaultAsync(x => x.Id == id); return(entity); }