public PagoCliente ConstruirPagoCliente(int idCliente) { PagoCliente pagoCliente = new PagoCliente { IdCliente = idCliente, FechaPago = DateTime.UtcNow, FechaVencimiento = DateTime.UtcNow.AddDays(30), MontoPago = 9.99, Impuesto = 7, MontoTotal = 10.69 }; return(pagoCliente); }
//************************************EntityFramework*********************************************************************************** public bool SetPagoCliente(PagoCliente model) { bool resultado = false; try { using (SudokuContext Context = new SudokuContext()) { Context.PagoCliente.Add(model); Context.SaveChanges(); resultado = true; } } catch (Exception ex) { InsertarSucesoLog(Funcion.ConstruirSucesoLog(ex.ToString().Substring(0, 300) + "*EngineDb/SetPagoCliente*")); } return(resultado); }
public ActionResult Registrar_PagoCliente(PagoCliente pago, string listaMonto, string listaFacturas, string listaEstado) { // try // { // TODO: Add insert logic here using (SqlConnection con = new SqlConnection("Server = DESKTOP-PQRUVP8\\SQLEXPRESS;Database=Veterimax;Trusted_Connection=True;")) { con.Open(); string[] listaPagos = listaMonto.Split(","); string[] listaVentas = listaFacturas.Split(","); string[] listaEst = listaEstado.Split(","); var cmd = con.CreateCommand(); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.CommandText = "Registrar_PagoCliente"; cmd.Parameters.AddWithValue("@IdCliente", pago.IdCliente); cmd.Parameters.AddWithValue("@Monto", pago.Monto); cmd.Parameters.AddWithValue("@FechaPago", DateTime.Now); cmd.Parameters.AddWithValue("@FechaRegistro", DateTime.Now); cmd.Parameters.AddWithValue("@IdUsuario", UsuarioController.idus); cmd.ExecuteNonQuery(); for (int i = 0; i < listaPagos.Length; i++) { var com = con.CreateCommand(); com.CommandType = System.Data.CommandType.StoredProcedure; com.CommandText = "Registrar_PagoClDetalle"; com.Parameters.AddWithValue("@IdVenta", int.Parse(listaVentas[i])); com.Parameters.AddWithValue("@Monto", decimal.Parse(listaPagos[i])); com.Parameters.AddWithValue("@Estado", listaEst[i]); ViewBag.Message = "Exito"; com.ExecuteNonQuery(); } con.Close(); } return(View("PagoCliente")); // } // catch // { // return View("PagoCliente"); // } }
public ActionResult Register(ActivarCliente model = null) { Respuesta R = new Respuesta(); if (model == null) { return(View(R)); } if (model.Email == null || model.Password == null || model.Password2 == null || model.Nombre == null || model.Apellido == null) { return(View(R)); } bool resultado = Funcion.EmailEsValido(model.Email); string emailCode64 = Funcion.ConvertirBase64(model.Email); if (!resultado) { //Email no valido R = Funcion.RespuestaProceso("Register", emailCode64, null, model.Email + EngineData.EmailNoValido()); return(RedirectToAction("State", "Home", R)); } resultado = Funcion.CompareString(model.Password, model.Password2); if (!resultado) { //Las contraseñas deben ser iguales R = Funcion.RespuestaProceso("Register", emailCode64, null, model.Email + EngineData.PasswordNoIdenticos()); return(RedirectToAction("State", "Home", R)); } model.Estatus = false; model.FechaRegistro = DateTime.UtcNow; model.Password = Funcion.ConvertirBase64(model.Email + model.Password); int result = Metodo.ClienteRegistro(model); if (result <= 0) { //Error al registrar cliente Funcion.ConstruirSucesoLog("Error registrando cliente*Home/Register*" + model.Email, Metodo); R = Funcion.RespuestaProceso("Register", emailCode64, null, model.Email + EngineData.ErrorRegistroCliente()); return(RedirectToAction("State", "Home", R)); } //*****************PAGO HARCODE************************** PagoCliente pago = Funcion.ConstruirPagoCliente(result); Metodo.SetPagoCliente(pago); //*************************************************** string enlaze = Funcion.CrearEnlazeRegistro(Metodo, model.Email, model.Password2); EstructuraMail estructura = new EstructuraMail(); estructura = Funcion.SetEstructuraMailRegister(enlaze, model.Email, estructura); resultado = Notificacion.EnviarMailNotificacion(estructura); if (resultado) { //Registro exitoso R = Funcion.RespuestaProceso("Index", emailCode64, null, model.Email + EngineData.RegistroExitoso()); return(RedirectToAction("State", "Home", R)); } else { //Error enviando notficacion - error interno Funcion.ConstruirSucesoLog("Error enviando email*Home/Register*" + model.Email, Metodo); R = Funcion.RespuestaProceso("Open", emailCode64, null, model.Email + EngineData.ErrorEnviandoMail()); return(RedirectToAction("State", "Home", R)); } }