Exemplo n.º 1
0
        public async Task <IHttpActionResult> PutPerfil([FromUri] int id, [FromUri] Perfil perfil)
        {
            if (Autorize.TeleyumaLogin(this.Request.Headers).ErrorCode > 0)
            {
                return(CreatedAtRoute("DefaultApi", null, Autorize.TeleyumaLogin(this.Request.Headers)));
            }


            if (id != perfil.Id)
            {
                return(BadRequest());
            }

            db.Entry(perfil).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PerfilExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 2
0
        public async Task <IHttpActionResult> PostPerfil([FromUri] Perfil perfil)
        {
            if (Autorize.TeleyumaLogin(this.Request.Headers).ErrorCode > 0)
            {
                return(CreatedAtRoute("DefaultApi", null, Autorize.TeleyumaLogin(this.Request.Headers)));
            }
            var exist = db.Perfil.ToList().Where(x => x.IdCuenta == perfil.IdCuenta);

            if (perfil.Foto is null)
            {
                return(CreatedAtRoute("DefaultApi", null, perfil));
            }

            if (exist.Any())
            {
                var f = exist.First();
                f.Foto = perfil.Foto;

                db.Entry(f).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(CreatedAtRoute("DefaultApi", new { id = f.Id }, f));
            }
            else
            {
                db.Perfil.Add(perfil);
                await db.SaveChangesAsync();

                return(CreatedAtRoute("DefaultApi", new { id = perfil.Id }, perfil));
            }
        }
Exemplo n.º 3
0
        // GET: api/Perfil
        public async Task <IHttpActionResult> GetPerfil()
        {
            if (Autorize.TeleyumaLogin(this.Request.Headers).ErrorCode > 0)
            {
                return(CreatedAtRoute("DefaultApi", null, Autorize.TeleyumaLogin(this.Request.Headers)));
            }

            return(CreatedAtRoute("DefaultApi", null, db.Perfil));
        }
Exemplo n.º 4
0
        public async Task <IHttpActionResult> PostPromo([FromUri] Promo promo)
        {
            if (Autorize.TeleyumaLogin(this.Request.Headers).ErrorCode > 0)
            {
                return(CreatedAtRoute("DefaultApi", null, Autorize.TeleyumaLogin(this.Request.Headers)));
            }

            db.Promo.Add(promo);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = promo.Id }, promo));
        }
Exemplo n.º 5
0
        public async Task <IHttpActionResult> PostSMS([FromUri] SMS sMS)
        {
            if (Autorize.TeleyumaLogin(this.Request.Headers).ErrorCode > 0)
            {
                return(CreatedAtRoute("DefaultApi", null, Autorize.TeleyumaLogin(this.Request.Headers)));
            }


            db.SMS.Add(sMS);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = sMS.Idsms }, sMS));
        }
Exemplo n.º 6
0
        public async Task <IHttpActionResult> Post([FromBody] ValidateProducto validateProducto)
        {
            if (Autorize.TeleyumaLogin(this.Request.Headers).ErrorCode > 0)
            {
                return(CreatedAtRoute("DefaultApi", null, Autorize.TeleyumaLogin(this.Request.Headers)));
            }

            var Product = await Ding.GetProductsByaccountNumber(validateProducto.Producto);

            var Provider = await Ding.GetProvidersByaccountNumber(validateProducto.Producto);


            if (Product is null || Provider is null)
            {
                return(CreatedAtRoute("DefaultApi", null, new { }));
            }
            if (!Product.Items.Any() || !Provider.Items.Any())
            {
                return(CreatedAtRoute("DefaultApi", null, new { }));
            }

            var promociones = db.DingPromo.Where(x => x.Estado == true && validateProducto.Monto >= x.Min && validateProducto.Monto <= x.Max).ToList();

            var result = new Producto();

            try
            {
                result.Code            = Product.Items.First().SkuCode;
                result.Image           = "producto.png";
                result.Name            = Provider.Items.First().Name;
                result.ProviderCode    = Provider.Items.First().ProviderCode;
                result.CountryIso      = Provider.Items.First().CountryIso;
                result.MinValue        = Product.Items.First().Minimum.SendValue;
                result.MaxValue        = Product.Items.First().Maximum.SendValue;
                result.CommissionRate  = (float)Product.Items.First().CommissionRate;
                result.ValidationRegex = Provider.Items.First().ValidationRegex;
                result.DisplayText     = Product.Items.First().DefaultDisplayText;
                if (promociones.Any())
                {
                    result.Bono = promociones.First().MontoText;
                }
            }
            catch (Exception)
            {
                return(CreatedAtRoute("DefaultApi", null, new { }));
            }

            return(CreatedAtRoute("DefaultApi", null, result));
        }
Exemplo n.º 7
0
        public async Task <IHttpActionResult> GetPromo([FromUri] int id)
        {
            if (Autorize.TeleyumaLogin(this.Request.Headers).ErrorCode > 0)
            {
                return(CreatedAtRoute("DefaultApi", null, Autorize.TeleyumaLogin(this.Request.Headers)));
            }

            Promo promo = await db.Promo.FindAsync(id);

            if (promo == null)
            {
                return(NotFound());
            }

            return(Ok(promo));
        }
Exemplo n.º 8
0
        public async Task <IHttpActionResult> GetPerfil([FromUri] string id)
        {
            if (Autorize.TeleyumaLogin(this.Request.Headers).ErrorCode > 0)
            {
                return(CreatedAtRoute("DefaultApi", null, Autorize.TeleyumaLogin(this.Request.Headers)));
            }

            try
            {
                var perfil = db.Perfil.ToList().Where(x => x.IdCuenta == id).Last();
                return(Ok(perfil));
            }
            catch (Exception ex)
            {
                return(Ok(new Perfil()));
            }
        }
Exemplo n.º 9
0
        public async Task <IHttpActionResult> GetSMS([FromUri] string id)
        {
            if (Autorize.TeleyumaLogin(this.Request.Headers).ErrorCode > 0)
            {
                return(CreatedAtRoute("DefaultApi", null, Autorize.TeleyumaLogin(this.Request.Headers)));
            }

            try
            {
                var sms = db.SMS.ToList().Where(x => x.Phone1 == id);
                return(Ok(sms));
            }
            catch (Exception ex)
            {
                return(Ok(new SMS()));
            }
        }
Exemplo n.º 10
0
        public async Task <IHttpActionResult> DeletePerfil([FromUri] int id)
        {
            if (Autorize.TeleyumaLogin(this.Request.Headers).ErrorCode > 0)
            {
                return(CreatedAtRoute("DefaultApi", null, Autorize.TeleyumaLogin(this.Request.Headers)));
            }


            Perfil perfil = await db.Perfil.FindAsync(id);

            if (perfil == null)
            {
                return(NotFound());
            }

            db.Perfil.Remove(perfil);
            await db.SaveChangesAsync();

            return(Ok(perfil));
        }
Exemplo n.º 11
0
        // POST: api/TopUp
        public async Task <IHttpActionResult> Post([FromBody] Teleyuma.Teleyuma.TopUpRequest topUpRequest)
        {
            if (Autorize.TeleyumaLogin(this.Request.Headers).ErrorCode > 0)
            {
                return(CreatedAtRoute("DefaultApi", null, Autorize.TeleyumaLogin(this.Request.Headers)));
            }

            //Transformar datos

            var DingRequest = new Ding.SendTransferRequest();

            DingRequest.SkuCode        = topUpRequest.SkuCode;
            DingRequest.AccountNumber  = topUpRequest.AccountNumber;
            DingRequest.SendValue      = topUpRequest.SendValue;
            DingRequest.DistributorRef = topUpRequest.DistributorRef;
            DingRequest.ValidateOnly   = topUpRequest.ValidateOnly;

            var result = await Ding.SendTransfer(DingRequest);

            return(CreatedAtRoute("DefaultApi", null, result));
        }