Exemplo n.º 1
0
        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)));
        }
Exemplo n.º 2
0
        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();
        }
Exemplo n.º 3
0
        public virtual async Task <TEntity> GetAsync(Guid id)
        {
            TEntity entity = await _context.Set <TEntity>().FirstOrDefaultAsync(x => x.Id == id);

            return(entity);
        }