SHARE
TWEET

Untitled

a guest Dec 15th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Threading.Tasks;
  5. using Microsoft.AspNetCore.Http;
  6. using Microsoft.AspNetCore.Mvc;
  7. using DBapplication;
  8. using Shoryan.Models;
  9. using Shoryan.Routes;
  10. using Newtonsoft.Json;
  11.  
  12. namespace Shoryan.Controllers
  13. {
  14.     [ApiController]
  15.     public class MODELNAMEController : Controller
  16.     {
  17.         DBManager dbMan;
  18.         public MODELNAMEController()
  19.         {
  20.             dbMan = new DBManager();
  21.         }
  22.  
  23.         [HttpPost("api/redeemGiftCard")]
  24.         public JsonResult redeemGiftCard([FromBody] Dictionary<string, object> JSONinput)
  25.         {
  26.             var giftCardsJson = JsonConvert.SerializeObject(JSONinput["giftCards"], Newtonsoft.Json.Formatting.Indented);
  27.             var giftCard = JsonConvert.DeserializeObject<GiftCards>(giftCardsJson);
  28.  
  29.             var normalUserJson = JsonConvert.SerializeObject(JSONinput["normalUser"], Newtonsoft.Json.Formatting.Indented);
  30.             var normalUser = JsonConvert.DeserializeObject<GiftCards>(normalUserJson);
  31.  
  32.             string StoredProcedureName = GiftCardsProcedures.redeemGiftCard;
  33.             Dictionary<string, object> Parameters = new Dictionary<string, object>();
  34.             Parameters.Add("@code", giftCard.code);
  35.             Parameters.Add("@claimingUserId", normalUser.id);
  36.  
  37.             return Json(dbMan.ExecuteNonQuery(StoredProcedureName, Parameters));
  38.         }
  39.  
  40.  
  41.     }
  42. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top