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)); }
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)); } }
// 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)); }
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)); }
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)); }
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)); }
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)); }
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())); } }
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())); } }
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)); }
// 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)); }