/// <summary> /// Deprecated Method for adding a new object to the Tickets EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToTickets(Ticket ticket) { base.AddObject("Tickets", ticket); }
/// <summary> /// Create a new Ticket object. /// </summary> /// <param name="pagoId">Initial value of the PagoId property.</param> /// <param name="folio">Initial value of the Folio property.</param> /// <param name="payCenterId">Initial value of the PayCenterId property.</param> /// <param name="tipoServicio">Initial value of the TipoServicio property.</param> /// <param name="leyenda">Initial value of the Leyenda property.</param> /// <param name="importe">Initial value of the Importe property.</param> /// <param name="comision">Initial value of the Comision property.</param> /// <param name="clienteNombre">Initial value of the ClienteNombre property.</param> /// <param name="clienteEmail">Initial value of the ClienteEmail property.</param> /// <param name="clienteTelefono">Initial value of the ClienteTelefono property.</param> /// <param name="fechaCreacion">Initial value of the FechaCreacion property.</param> /// <param name="baja">Initial value of the Baja property.</param> /// <param name="fechaVencimiento">Initial value of the FechaVencimiento property.</param> /// <param name="payCenterName">Initial value of the PayCenterName property.</param> public static Ticket CreateTicket(global::System.Int32 pagoId, global::System.String folio, global::System.Int32 payCenterId, global::System.String tipoServicio, global::System.String leyenda, global::System.Decimal importe, global::System.Decimal comision, global::System.String clienteNombre, global::System.String clienteEmail, global::System.String clienteTelefono, global::System.DateTime fechaCreacion, global::System.Boolean baja, global::System.DateTime fechaVencimiento, global::System.String payCenterName) { Ticket ticket = new Ticket(); ticket.PagoId = pagoId; ticket.Folio = folio; ticket.PayCenterId = payCenterId; ticket.TipoServicio = tipoServicio; ticket.Leyenda = leyenda; ticket.Importe = importe; ticket.Comision = comision; ticket.ClienteNombre = clienteNombre; ticket.ClienteEmail = clienteEmail; ticket.ClienteTelefono = clienteTelefono; ticket.FechaCreacion = fechaCreacion; ticket.Baja = baja; ticket.FechaVencimiento = fechaVencimiento; ticket.PayCenterName = payCenterName; return ticket; }
public ActionResult Create(PagoVM model) { if (PayCenterId == 0) { model.PayCenterName = string.Empty; AddValidationMessage(enumMessageType.DataValidation, "Por favor, seleccione primero un PayCenter."); return View(model); } EstadoCuentaBR br = new EstadoCuentaBR(repository.context); var saldo = br.GetSaldosPagoServicio(PayCenterId); ViewData["SaldoActual"] = saldo.SaldoActual.ToString("C"); ViewData["SaldoDisponible"] = saldo.SaldoDisponible.ToString("C"); ViewData["Eventos"] = saldo.EventosDisponibles; if (model.Importe <= 0) { AddValidationMessage(enumMessageType.DataValidation, "El importe no puede ser menor a $0.00."); return View(model); } if (ModelState.IsValid) { #region Crear Movimiento Inicial Pago pago = new Pago(); PaycenterBR payCenterBR = new PaycenterBR(); var cuentaId = payCenterBR.GetOrCreateCuentaPayCenter(PayCenterId, enumTipoCuenta.Pago_de_Servicios, PROVEEDOR_EVOLUCIONAMOVIL); //Devuelve si usa evento en el pago bool usaEvento = false; List<Movimiento> movimientos = br.CrearMovimientosPagoServicios(PayCenterId, (Decimal)model.Importe, PayCenterName, out usaEvento); Succeed = br.Succeed; ValidationMessages = br.ValidationMessages; if (!Succeed) { return View(model); } #endregion #region Registro de Pago string Referencia = ""; Mapper.CreateMap<PagoVM, Pago>().ForMember(dest => dest.DetallePagos, opt => opt.Ignore()); Mapper.Map(model, pago); pago.Servicio = model.Servicios.Where(x => x.Value == model.ServicioId).FirstOrDefault().Text; pago.PayCenterId = PayCenterId; pago.Movimiento = movimientos.Where(x => x.Motivo == (short)enumMotivo.Pago).First(); pago.UsoEvento = usaEvento; var iDetalles = serviciosRepository.LoadDetallesServicioByServicioID(pago.ServicioId); foreach (DetalleServicio d in iDetalles) { var valor = Request.Form[d.DetalleServicioId.ToString()]; if (d.EsReferencia) Referencia = valor; pago.DetallePagos.Add(new DetallePago { Campo = d.Campo, Valor = valor }); } repository.Add(pago); repository.Save(); //Actualizo el Id de referencia del Pago en los movimientos correspondientes br.ActualizaReferenciaIdMovimiento(pago.MovimientoId, pago.PagoId); repository.Save(); model.PagoId = pago.PagoId; #endregion #region Registro Ticket try { //Verifica si tiene configurada la comisión que mostrará al cliente, se toma el valor para mostrar en el ticket ParametrosRepository parametrosRepository = new ParametrosRepository(); var parametrosPayCenter = parametrosRepository.GetParametrosPayCenter(PayCenterId); var parametrosGlobales = parametrosRepository.GetParametrosGlobales(); Ticket ticket = new Ticket(); ticket.ClienteEmail = ""; ticket.ClienteNombre = pago.ClienteNombre; ticket.ClienteTelefono = ""; ticket.Comision = (parametrosPayCenter != null && parametrosPayCenter.ComisionCliente != null ? (Decimal)parametrosPayCenter.ComisionCliente : 0); //Comision configurada del paycenter ticket.FechaCreacion = DateTime.UtcNow.GetCurrentTime(); ticket.Folio = createFolio(pago.PagoId); ticket.Importe = pago.Importe; ticket.Leyenda = parametrosGlobales != null ? parametrosGlobales.LeyendaTicket : null; ticket.PagoId = pago.PagoId; ticket.PayCenterId = pago.PayCenterId; ticket.TipoServicio = pago.Servicio; ticket.Referencia = Referencia; ticket.PayCenterName = PayCenterName; ticket.FechaVencimiento = pago.FechaVencimiento; tRepository.Add(ticket); Succeed = tRepository.Save(); if (!Succeed) { AddValidationMessage(enumMessageType.UnhandledException, "Su pago ha sido Registrado con éxito. Sin embargo, no se pudo generar el ticket, favor de comunicarse con un ejecutivo. "); } //Ejecuta el envío de correo de forma asíncrona EnviarTicketDelegate enviarDelegate = new EnviarTicketDelegate(EnviarTicketEmail); var result = enviarDelegate.BeginInvoke(pago,null, null); return RedirectToAction("Ticket/" + ticket.PagoId.ToString()); } catch (Exception ex) { AddValidationMessage(enumMessageType.UnhandledException, "Su pago ha sido Registrado con éxito. Sin embargo, no se pudo generar el ticket, favor de comunicarse con un ejecutivo. "); return View(model); } #endregion } else { AddValidationMessage(enumMessageType.BRException, "Los datos no son válidos"); } return View(model); }