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()); } }
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)); }
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); }