public async Task <IActionResult> Edit(int id, Recarga recarga) { if (id != recarga.id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(recarga); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RecargaExists(recarga.id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(recarga)); }
public async Task <IHttpActionResult> PostRecarga(RecargaBindingModel recargaModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Usuario user = await db.Users.FirstAsync(u => u.Email == User.Identity.Name); Cliente cliente = await db.Clientes.FindAsync(recargaModel.IdCliente); decimal saldoAtual = cliente.Saldo; Recarga recarga = new Recarga() { Cliente = cliente, Data = DateTime.Now, Usuario = user, Valor = recargaModel.Valor }; cliente.Saldo = saldoAtual + recargaModel.Valor; db.Recargas.Add(recarga); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = recarga.Id }, recarga)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,MontoId,PhoneNumber,CarrierId,DateCreated,DateResolved,StatusCode,WebServDescId,IdentityUserId")] Recarga recarga) { if (id != recarga.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(recarga); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RecargaExists(recarga.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CarrierId"] = new SelectList(_context.Carriers.AsNoTracking(), "Id", "CarrierName", recarga.CarrierId); ViewData["MontoId"] = new SelectList(_context.Montos.AsNoTracking(), "Id", "MontoCant", recarga.MontoId); ViewData["WebServDescId"] = new SelectList(_context.WebServDescs.AsNoTracking(), "Id", "WebServiceName", recarga.WebServDescId); return(View(recarga)); }
public Recarga ToRecarga(DateTime now) { Recarga r = new Recarga(); r.Monto = Monto; r.ClientId = ClientId; r.OperardorId = OperardorId; r.DateCreated = now; return(r); }
public async Task <IHttpActionResult> GetRecarga(int id) { Recarga recarga = await db.Recargas.FindAsync(id); if (recarga == null) { return(NotFound()); } return(Ok(recarga)); }
public ActionResult ActualizarFase(string recargaId, short fase) { Recarga oRecarga = db.Recarga.First(x => x.RecargaId == recargaId); oRecarga.Fase = fase; oRecarga.FechaSurtido = DateTime.Now; oRecarga.MFechaHora = DateTime.Now; oRecarga.MUsuarioId = ObtenerUsuario(); db.SaveChanges(); return(Json(new { result = true }, JsonRequestBehavior.AllowGet)); }
public async Task <IHttpActionResult> DeleteRecarga(int id) { Recarga recarga = await db.Recargas.FindAsync(id); if (recarga == null) { return(NotFound()); } db.Recargas.Remove(recarga); await db.SaveChangesAsync(); return(Ok(recarga)); }
public async Task <IActionResult> Create([Bind("Id,MontoId,PhoneNumber,CarrierId,ConfirmPhone")] Recarga recarga) {//,DateCreated,DateResolved,StatusCode,WebServDescId,IdentityUserId if (ModelState.IsValid) { recarga.DateCreated = Double.Parse(DateTime.Now.Millisecond.ToString()); recarga.StatusId = 1; recarga.StatusCode = 0; _context.Add(recarga); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CarrierId"] = new SelectList(_context.Carriers.AsNoTracking(), "Id", "CarrierName", recarga.CarrierId); ViewData["MontoId"] = new SelectList(_context.Montos.AsNoTracking(), "Id", "MontoCant", recarga.MontoId); ViewData["WebServDescId"] = new SelectList(_context.WebServDescs.AsNoTracking(), "Id", "WebServiceName", recarga.WebServDescId); return(View(recarga)); }
public void AñadirRecarga(Estacion estacion, Tarjetum tarjeta, DateTime fecha, DateTime hora) { using (EntitiesModel dbContext = new EntitiesModel()) { Recarga recarga = new Recarga(); recarga.Estacion = estacion ; recarga.Tarjetum = tarjeta; recarga.Fecha = fecha; recarga.Hora = hora; dbContext.Add(recarga); dbContext.SaveChanges(); } }
protected void Button1_Click(object sender, EventArgs e) { DateTime hoy = DateTime.Now; Recarga objRecarga = new Recarga(); objRecarga.Fecha = DateTime.Now; objRecarga.Monto = int.Parse(txtMonto.Text); objRecarga.Numero = int.Parse(cmbTelefono.SelectedValue); //objRecarga.Fecha = hoy.ToString("dd/MM/yyyy"); objRecarga.ingresar(objRecarga); lblMensaje.Text = "*" + objRecarga.Mensaje + "*"; lblMensaje.Visible = true; txtMonto.Text = ""; //DateTime hoy = DateTime.Now; //string miVariable = hoy.ToString("dd/MM/yyyy"); }
public static async Task <SendTransferResponse> SendTransfer(Recarga recarga, string token) { SendTransferRequest entity = new SendTransferRequest(); if (recarga.tipoRecarga == TipoRecarga.movil) { entity.SkuCode = "CU_CU_TopUp"; } else if (recarga.tipoRecarga == TipoRecarga.nauta) { entity.SkuCode = "CU_NU_TopUp"; } entity.AccountNumber = recarga.numero; entity.SendValue = (float)recarga.valor; entity.ValidateOnly = Ding.simulate; entity.DistributorRef = $"cuenta_{recarga.idCuenta}"; using (var client = new HttpClient()) { client.DefaultRequestHeaders.Clear(); client.DefaultRequestHeaders.Add("api_key", token); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); try { var url2 = "https://api.dingconnect.com/api/V1/SendTransfer"; var response = await client.PostAsJsonAsync(url2, entity); var result = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <SendTransferResponse>(result)); } catch (Exception ex) { return(default(SendTransferResponse)); } } }
public async Task <IActionResult> Init() { IdentityRole ad = new IdentityRole(RTRoles.Admin); ad.NormalizedName = RTRoles.Admin.ToUpper(); await _dbContext.Roles.AddAsync(ad); IdentityRole cl = new IdentityRole(RTRoles.Client); cl.NormalizedName = RTRoles.Client.ToUpper(); await _dbContext.Roles.AddAsync(cl); IdentityRole ag = new IdentityRole(RTRoles.Agent); ag.NormalizedName = RTRoles.Agent.ToUpper(); await _dbContext.Roles.AddAsync(ag); IdentityUser raf = new IdentityUser("*****@*****.**"); await _userManager.CreateAsync(raf, "Ciber*2019"); raf = await _userManager.FindByNameAsync("*****@*****.**"); await _userManager.AddToRoleAsync(raf, RTRoles.Admin); Recarga rc = new Recarga() { ClientId = raf.Id, Monto = 0, OperardorId = raf.Id, DateCreated = DateTime.Now }; await _dbContext.AddAsync <Recarga>(rc); await _dbContext.SaveChangesAsync(); return(Ok()); }
public async Task RecargarUsuario(RecargaDTO recargaDTO) { DateTime now = DateTime.Now.ToUtcCuba(); Recarga r = recargaDTO.ToRecarga(now); await _unitOfWork.Recarga.AddAsync(r); Cuenta c = await _unitOfWork.Cuenta.FindAsync(t => t.UserId == r.ClientId); c.Saldo += r.Monto; Notificacion notificacion = new Notificacion() { UserId = recargaDTO.ClientId, DateCreated = now, Mensaje = String.Format("Cuenta recargada: ${0}. Su saldo actual es de {1}", recargaDTO.Monto, c.Saldo), Readed = false }; await _notificationsService.Add(notificacion); await _unitOfWork.Cuenta.UpdateAsync(c, c.Id); await _unitOfWork.SaveChangesAsync(); }
public ActionResult IncluirRecarga(RecargaModel recargaModel) { Recarga recarga = new Recarga { Id = recargaModel.Id, TelefoneId = recargaModel.TelefoneId, FormaPagId = recargaModel.FormaPagId, Data = DateTime.Now, Valor = recargaModel.Valor }; if (recarga.Id <= 0) { entity.Recarga.Add(recarga); } else { entity.Entry(recarga).State = EntityState.Modified; } entity.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <IActionResult> Create(Recarga recarga) { IsLogged(); try { var cuentaActiva = await ValidarCuentaActiva(); if (!cuentaActiva) { return(RedirectToAction("Salir", "Login")); } SetSession("Recarga", recarga); var configuracion = await _context.RT_Configuracion.ToListAsync(); var tasaCambioCUP = configuracion.FirstOrDefault().tasaCambioCUP; var RecargasEnLista = await _context.RT_Recargas.Where(x => x.idCuenta == Logged.IdCuenta && (x.status == RecargaStatus.en_lista || x.status == RecargaStatus.error) && x.activo).ToListAsync(); if (RecargasEnLista.Count() >= 10) { PrompErro("Solo puede enviar 10 recargas por vez."); return(RedirectToAction(nameof(Index))); } //Validar fondos var recargaValor = await _context.RT_RecargaValores.FirstOrDefaultAsync(x => x.id == recarga.idValorRecarga); recarga.valor = recargaValor.valor; recarga.recibe = recargaValor.valor * tasaCambioCUP; var valorLista = RecargasEnLista.Where(x => x.status == RecargaStatus.en_lista && x.idCuenta == Logged.IdCuenta).Sum(x => x.monto); var totalLisat = valorLista + recarga.GetMonto(Logged.Porciento); var fondos = await GetFondos(); if (fondos < totalLisat) { PrompErro("No tiene saldo suiciente para agregar esta recarga"); return(RedirectToAction(nameof(Index))); } if (recarga.nauta is not null && recarga.tipoRecarga == TipoRecarga.nauta) { recarga.numero = recarga.nauta; recarga.bono = null; ModelState["Numero"].ValidationState = ModelValidationState.Valid; } if (ModelState.IsValid) { try { recarga.idCuenta = Logged.IdCuenta; recarga.status = RecargaStatus.en_lista; recarga.activo = true; if (recarga.tipoRecarga == TipoRecarga.movil) { var numero = "53" + recarga.numero; if (RecargasEnLista.Where(x => x.numero == numero).Any()) { PrompErro("Para recargar el mismo número espere 5 minutos."); return(RedirectToAction(nameof(Index))); } recarga.numero = numero; } else if (recarga.tipoRecarga == TipoRecarga.nauta) { var numero = recarga.numero + "@nauta.com.cu"; if (RecargasEnLista.Where(x => x.numero == numero).Any()) { PrompErro("Para recargar el mismo usuario nauta espere 5 minutos."); return(RedirectToAction(nameof(Index))); } recarga.numero = numero; } _context.Add(recarga); await _context.SaveChangesAsync(); SetSession("Recarga", ""); return(RedirectToAction(nameof(Index))); } catch (Exception ex) { PrompErro(ex.Message); } } } catch (Exception ex) { PrompErro(ex.Message); } return(RedirectToAction(nameof(Index))); }
protected override void Update(GameTime gameTime) { //Limitaciones de la pantalla Position.X = MathHelper.Clamp(Position.X, 15, ancho - 15); Position.Y = MathHelper.Clamp(Position.Y, 15, alto - 15); KeyboardState keyState = Keyboard.GetState(); if (keyState.IsKeyDown(Keys.Escape)) { Exit(); } //Pausa if (keyState.IsKeyDown(Keys.P)) { pause = true; } if (keyState.IsKeyDown(Keys.Space)) { pause = false; } if (pause == true) { if (musicp == false) { P = Content.Load <Song> ("Musica/Lzn02-The Dolls Death.wav"); MediaPlayer.Play(P); musicp = true; } return; } if ((pause == false) && (Nivel == 1)) { if (musicn1 == false) { N1 = Content.Load <Song> ("Musica/Nosphares-Strengths Of Evil.wav"); MediaPlayer.Play(N1); musicn1 = true; } } if ((pause == false) && (Nivel == 2)) { if (musicn2 == false) { N2 = Content.Load <Song> ("Musica/Shamatronic-Jack the Pirate.wav"); MediaPlayer.Play(N2); musicn2 = true; } } if ((pause == true) && (over == true)) { if (musicf == false) { F = Content.Load <Song> ("Musica/Akashic-Stories of The Old Mansion.wav"); MediaPlayer.Play(F); musicf = true; } } //Teclado MouseState newMouse = Mouse.GetState(); if (keyState.IsKeyDown(Keys.A)) { Position.X -= 2.5f; } if (keyState.IsKeyDown(Keys.D)) { Position.X += 2.5f; } if (keyState.IsKeyDown(Keys.W)) { Position.Y -= 2.5f; } if (keyState.IsKeyDown(Keys.S)) { Position.Y += 2.5f; } if (keyState.IsKeyDown(Keys.S) && keyState.IsKeyDown(Keys.A)) { Position.Y -= 0.80f; Position.X += 0.80f; } if (keyState.IsKeyDown(Keys.S) && keyState.IsKeyDown(Keys.D)) { Position.Y -= 0.80f; Position.X -= 0.80f; } if (keyState.IsKeyDown(Keys.W) && keyState.IsKeyDown(Keys.A)) { Position.Y += 0.80f; Position.X += 0.80f; } if (keyState.IsKeyDown(Keys.W) && keyState.IsKeyDown(Keys.D)) { Position.Y += 0.80f; Position.X -= 0.80f; } //Recarga if (keyState.IsKeyDown(Keys.R)) { if (!oldKey.IsKeyDown(Keys.R)) { Recarga.Play(); balas = 12; } } if (balas <= 0) { disp = false; } if (balas > 0) { disp = true; } TR = TR - (float)(gameTime.ElapsedGameTime.TotalSeconds); PlayerR = new Rectangle((int)Position.X, (int)Position.Y, Player.Width, Player.Height); if (Nivel == 1) { Fondo = Content.Load <Texture2D> ("Imagenes/Pasto"); if (aleatorio.NextDouble() < probabilidadEnemigo) { float y = (float)aleatorio.NextDouble() * 700; posicionesEnemigo.Add(new Vector2(0, y)); } for (int i = 0; i < posicionesEnemigo.Count; i++) { posicionesEnemigo [i] = new Vector2(posicionesEnemigo [i].X + 0.8f, posicionesEnemigo [i].Y); Zombie1 = new Rectangle((int)posicionesEnemigo [i].X + 15, (int)posicionesEnemigo [i].Y + 15, Z1.Width, Z1.Height); if ((PlayerR.Intersects(Zombie1)) || (ZP == 5)) { over = true; } if (posicionesEnemigo [i].X > Window.ClientBounds.Width) { posicionesEnemigo.RemoveAt(i); i--; ZP++; } if (disp == true) { if (newMouse.LeftButton == ButtonState.Pressed) { if (oldMouse.LeftButton != ButtonState.Pressed) { if (new Rectangle(Mouse.GetState().X + 11, Mouse.GetState().Y + 11, 1, 1).Intersects(Zombie1)) { resZ--; D++; if (resZ == 0) { posicionesEnemigo.RemoveAt(i); i--; ZM++; resZ = 2; } } else if (oldMouse.LeftButton == ButtonState.Pressed) { Player = Content.Load <Texture2D> ("Jugador/Pisto"); } } } } } if (TR <= 0) { posicionesEnemigo.Clear(); Position = new Vector2(500, 375); Nivel++; Z1 = Content.Load <Texture2D> ("Zombies/Z2"); Position = new Vector2(500, 375); balas = 12; pause = true; TR = 70; } } if (Nivel == 2) { Fondo = Content.Load <Texture2D> ("Imagenes/Tierra"); if (aleatorio.NextDouble() < probabilidadEnemigo) { float x = (float)aleatorio.NextDouble() * Window.ClientBounds.Height; posicionesEnemigo.Add(new Vector2(x, 0)); } for (int i = 0; i < posicionesEnemigo.Count; i++) { posicionesEnemigo [i] = new Vector2(posicionesEnemigo [i].X, posicionesEnemigo [i].Y + 1); Zombie1 = new Rectangle((int)posicionesEnemigo [i].X + 10, (int)posicionesEnemigo [i].Y + 15, Z1.Width, Z1.Height); if ((PlayerR.Intersects(Zombie1)) || (ZP == 5)) { over = true; } if (posicionesEnemigo [i].Y > Window.ClientBounds.Height) { posicionesEnemigo.RemoveAt(i); i--; ZP++; } if (disp == true) { if (newMouse.LeftButton == ButtonState.Pressed) { if (oldMouse.LeftButton != ButtonState.Pressed) { if (new Rectangle(Mouse.GetState().X + 11, Mouse.GetState().Y + 11, 1, 1).Intersects(Zombie1)) { resZ--; D++; if (resZ == 0) { posicionesEnemigo.RemoveAt(i); i--; ZM++; resZ = 2; } } else if (oldMouse.LeftButton == ButtonState.Pressed) { Player = Content.Load <Texture2D> ("Jugador/Pisto"); } } } } } } if (disp == true) { if (newMouse.LeftButton == ButtonState.Pressed) { if (oldMouse.LeftButton != ButtonState.Pressed) { balas--; PistoS.Play(); Player = Content.Load <Texture2D> ("Jugador/PistoA"); } } else if (oldMouse.LeftButton == ButtonState.Pressed) { Player = Content.Load <Texture2D> ("Jugador/Pisto"); } } oldKey = keyState; oldMouse = newMouse; Vector2 mouseLoc = new Vector2(newMouse.X, newMouse.Y); Vector2 direction = mouseLoc - Position; angle = (float)(Math.Atan2(direction.Y, direction.X)); base.Update(gameTime); }
// GET: Recargas public async Task <IActionResult> Index(bool success = false) { IsLogged(); await GetFondos(); var recarga = new Recarga(); var recargasEnLista = new List <Recarga>(); try { recargasEnLista = await _context.RT_Recargas.Where(x => x.idCuenta == Logged.IdCuenta && (x.status == RecargaStatus.en_lista || x.status == RecargaStatus.error) && x.activo).ToListAsync(); ViewBag.RecargasEnLista = recargasEnLista; var numeroSemana = DateTime.Now.GetSemana(); var year = DateTime.Now.ToEasternStandardTime().Year; var semana = $"{year}-W{numeroSemana}"; if (numeroSemana < 10) { semana = $"{year}-W0{numeroSemana}"; } var promo = await _context.RT_Promociones.Where(x => x.semana == semana && x.activo).FirstOrDefaultAsync(); if (promo != null) { ViewBag.Promocion = promo.texto; ViewBag.Bono = promo.bono; } if (GetSession <Recarga>("Recarga") != null) { recarga = GetSession <Recarga>("Recarga"); if (recarga.numero is null && recarga.tipoRecarga == TipoRecarga.movil) { PrompErro("Ingrese el número"); } if (recarga.nauta is null && recarga.tipoRecarga == TipoRecarga.nauta) { PrompErro("Ingrese el usuario"); } } } catch (Exception ex) { PrompErro(ex.Message); } if (recargasEnLista.Any() && recargasEnLista.Where(x => x.status == RecargaStatus.error).Any()) { ViewBag.RecargasConError = true; } ; if (success) { NotifySuccess("Recargas enviadas correctamente."); } ; return(View(recarga)); }