Example #1
0
        public async Task <ActionResult> CreateCard(Dcard card, CancellationToken token)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var cardd = new Dcard
                    {
                        _id        = ObjectId.GenerateNewId().ToString(),
                        CardNumber = card.CardNumber,
                        balance    = card.balance,
                        month      = card.month,
                        year       = card.year,
                        CVV        = card.CVV, mailid = card.mailid
                    };
                    await _classRepository.CreateCardAsync(cardd, token);

                    return(RedirectToAction(nameof(Index)));
                }
                else
                {
                    return(View());
                }
            }
            catch
            {
                return(View());
            }
        }
Example #2
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,CardNumber,month,year,CVV,mailid,balance")] Dcard dcard)
        {
            if (id != dcard.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(dcard);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DcardExists(dcard.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(dcard));
        }
Example #3
0
        public async Task <IActionResult> Create([Bind("ID,CardNumber,month,year,CVV,mailid,balance")] Dcard dcard)
        {
            if (ModelState.IsValid)
            {
                _context.Add(dcard);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(dcard));
        }
 public void updateCard(Dcard card)
 {
     _Cards.ReplaceOne(item => item._id == card._id, card);
 }
        public virtual async Task <IdentityResult> CreateCardAsync(Dcard card, CancellationToken token)
        {
            await _Cards.InsertOneAsync(card, cancellationToken : token);

            return(IdentityResult.Success);
        }