Exemplo n.º 1
0
        public async Task <TEntity> UpdateAsync(TEntity entity, CancellationToken cancellationToken)
        {
            _dbContext.Entry(entity).State = EntityState.Modified;
            //?
            await _dbContext.SaveChangesAsync(cancellationToken);

            return(entity);
        }
Exemplo n.º 2
0
        public async Task <ActionResult <Budget> > PostBudget(Budget budget)
        {
            //Budget budget = new Budget();
            //budget = JsonSerializer.Deserialize<Budget>(jsonString);
            _context.Budget.Add(budget);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetBudget", new { id = budget.Id }, budget));
        }
Exemplo n.º 3
0
        public async Task <T> CreateAsync(T entity, bool saveChanges = true)
        {
            await _budgetDbContext.AddAsync(entity);

            if (saveChanges)
            {
                await _budgetDbContext.SaveChangesAsync();
            }

            return(entity);
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Create([Bind("Id,Nom,Ville")] Banque banque)
        {
            if (ModelState.IsValid)
            {
                banque.Id = Guid.NewGuid();
                _context.Add(banque);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(banque));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> Create([Bind("IdCompte,Date,Libelle,Debit,Montant")] Ecriture ecriture)
        {
            if (ModelState.IsValid)
            {
                ecriture.Id = Guid.NewGuid();
                _context.Add(ecriture);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(ecriture));
        }
Exemplo n.º 6
0
        public async Task <IActionResult> Create([Bind("Id,Numero,Type,IdPersonne,IdBanque")] Compte compte)
        {
            if (ModelState.IsValid)
            {
                compte.Id = Guid.NewGuid();
                _context.Add(compte);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(compte));
        }
Exemplo n.º 7
0
        public async Task <IActionResult> Create([Bind("Id,Nom,Prenom,DateDeNaissance,Mail")] Personne personne)
        {
            if (ModelState.IsValid)
            {
                personne.Id = Guid.NewGuid();
                _context.Add(personne);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(personne));
        }
Exemplo n.º 8
0
        public async void UpdateSubs(string userId = "")
        {
            List <Subscription> subs     = _context.Subscription.Where(s => s.UserId == userId).ToList();
            List <string>       subNames = new List <string>()
            {
            };
            List <int> due = new List <int>()
            {
            };
            var date = DateTime.Now.Date;

            for (var i = 0; i < subs.Count; i++)
            {
                if (subs[i].NextDue.Date <= date)
                {
                    due.Add(subs[i].SubscriptionId);
                    subs[i].OverDue = "OVERDUE";
                    subNames.Add(subs[i].SubscriptionName);
                }
                else
                {
                    subs[i].OverDue = "More";
                }
            }
            await _context.SaveChangesAsync();

            await Clients.Caller.SendAsync("UpdateSubs", due);

            await Clients.Caller.SendAsync("subDue", subNames);
        }
Exemplo n.º 9
0
        private static async Task SeedAsync(this BudgetDbContext context, RoleManager <IdentityRole> roleManager)
        {
            await context.AddRolesAsync(roleManager);

            await context.AddCurrenciesAsync();

            await context.AddPaymentTypesAsync();

            await context.AddCategoriesAsync();

            await context.SaveChangesAsync();
        }
Exemplo n.º 10
0
 public async Task <int> CompleteAsync()
 {
     return(await _context.SaveChangesAsync());
 }