public async Task <IActionResult> Create([Bind("CourseID,CourseName,Credits,Online")] Courses courses) { if (ModelState.IsValid) { _context.Add(courses); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(courses)); }
public async Task <bool> UpdateCreditCard(CreditCard card) { var creditCard = await context.CreditCard.FirstOrDefaultAsync(x => x.Id == card.Id); if (creditCard == null) { return(false); } if (creditCard.UserId != card.UserId) { return(false); } var encryptedContent = this.cryptoService.EncryptContent(card.PTCC); var signedContent = this.cryptoService.SignContent(Convert.FromBase64String(encryptedContent)); try { creditCard.ECC = encryptedContent; creditCard.SECC = signedContent; creditCard.CvcCode = dataProtector.Protect(card.CvcCode); await context.SaveChangesAsync(); } catch (Exception e) { Console.WriteLine(e); return(false); } return(true); }
public async Task <IActionResult> DeleteConfirmed(Guid id) { var creditCard = await _context.CreditCard.SingleOrDefaultAsync(m => m.Id == id); var user = await _userManager.GetUserAsync(HttpContext.User); if (creditCard.UserId != user.Id) { RedirectToAction("Index"); } _context.CreditCard.Remove(creditCard); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }