public async Task <IActionResult> Recargar(string ClientId, int ValorRecarga, bool detallesView) { if (ValorRecarga <= 0) { return(BadRequest()); } IdentityUser user = await _userManager.GetUserAsync(User); RecargaDTO r = new RecargaDTO(user.Id, ClientId, ValorRecarga); await _userControlService.RecargarCliente(r); if (detallesView) { ClientDetalles model = await BuildDetallesModel(ClientId); return(PartialView(nameof(Detalles), model)); } return(await BuildPartialView()); }
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 async Task RecargarCliente(RecargaDTO recargaDTO) { await _financieroService.RecargarUsuario(recargaDTO); await _temporizadorService.SetSystemEnable(recargaDTO.ClientId, true); }