Пример #1
0
 public async Task <IActionResult> PostEditCardDetailsApi(int id, [FromBody] CardDetails cardDetails)
 {
     if (ModelState.IsValid)
     {
         try
         {
             cardDetails.CardId = id;
             _context.Update(cardDetails);
             await _context.SaveChangesAsync();
         }
         catch (DbUpdateConcurrencyException)
         {
             if (!CardDetailsExists(cardDetails.CardId))
             {
                 return(NotFound());
             }
             else
             {
                 throw;
             }
         }
         return(Json("Success"));
     }
     return(Json("Fail"));
 }
Пример #2
0
        public async Task <IActionResult> Edit(int id, [Bind("CardId,Type,Digits,ExpirationMonth,ExpirationYear")] CardDetails cardDetails)
        {
            if (id != cardDetails.CardId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(cardDetails);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CardDetailsExists(cardDetails.CardId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(cardDetails));
        }
Пример #3
0
        // [FromBody]dynamic cardDetails
        public async Task <IActionResult> PostAddCardDetailsApi([FromBody] CardDetails cardDetails)
        {
            Console.WriteLine(cardDetails);
            _context.Add(cardDetails);
            await _context.SaveChangesAsync();

            return(Json(cardDetails.CardId));
        }
Пример #4
0
        public async Task <IActionResult> Create([Bind("CardId,Type,Digits,ExpirationMonth,ExpirationYear")] CardDetails cardDetails)
        {
            if (ModelState.IsValid)
            {
                _context.Add(cardDetails);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(cardDetails));
        }
Пример #5
0
        public async Task <IActionResult> PostAddCardDetailsValidationApi([FromBody] CardDetails cardDetails)
        {
            if (ModelState.IsValid)
            {
                _context.Add(cardDetails);
                await _context.SaveChangesAsync();

                return(Json(cardDetails.CardId));
            }
            else
            {
                return(Json("Fail"));
            }
        }