예제 #1
0
        private ModelQrCreate Post([FromBody] int idDiscount, int idCommerce)
        {
            QrCode        xqr     = new QrCode();
            ModelQrCreate xqrResp = new ModelQrCreate();

            xqr.IdDiscount = idDiscount;
            xqr.IdCommerce = idCommerce;
            var userid = ObtenerIDUser();

            xqr.IdUser         = userid;
            xqr.TimeValidation = DateTime.Today.AddDays(1);
            xqr.DateCreate     = DateTime.Today;


            if (xqr.IdDiscount > 0)
            {
                context.QrCode.Add(xqr);
                context.SaveChanges();

                Put(xqr);
                xqrResp.Id         = xqr.Id;
                xqrResp.IdCommerce = xqr.IdCommerce;
                xqrResp.IdDiscount = xqr.IdDiscount;
                xqrResp.IdUser     = xqr.IdUser;
                xqrResp.Image      = xqr.Image;
                xqrResp.Valued     = xqr.Valued;



                return(xqrResp);
            }

            return(null);
        }
예제 #2
0
        public IActionResult Get(int idDiscount, int idCommerce)
        {
            ModelQrCreate xqr = new ModelQrCreate();

            xqr = Post(idDiscount, idCommerce);
            if (xqr == null)
            {
                return(BadRequest());
            }
            return(Ok(new { results = xqr }));
        }