public ActionResult AddNewRoute(string provincia, string canton, string nombre, decimal costo)
        {
            if (string.IsNullOrEmpty(provincia) || string.IsNullOrEmpty(canton) || string.IsNullOrEmpty(nombre) || string.IsNullOrEmpty(costo.ToString()))
            {
                return(RedirectToAction("Routes", "Admin", new { message = "Campos vacíos", provincia = provincia, canton = canton, nombre = nombre, costo = costo }));
            }


            if (costo < 1)
            {
                return(RedirectToAction("Routes", "Admin", new { message = "Costo debe ser mayor a 0", provincia = provincia, canton = canton, nombre = nombre, costo = costo }));
            }


            if (IsRegisteredName(nombre.Trim()))
            {
                return(RedirectToAction("Routes", "Admin", new { message = "Nombre de la ruta ya existe", provincia = provincia, canton = canton, nombre = nombre, costo = costo }));
            }


            var ruta = new RUTA();

            ruta.RUT_PROVINCIA = provincia.Trim();
            ruta.RUT_CANTON    = canton.Trim();
            ruta.RUT_NOMBRE    = nombre.Trim();
            ruta.RUT_COSTO     = costo;
            ruta.RUT_ESTADO    = true;

            SMART_PAYMENT_DBEntities db = new SMART_PAYMENT_DBEntities();

            db.Entry(ruta).State = System.Data.Entity.EntityState.Added;
            db.SaveChanges();

            return(RedirectToAction("Routes", "Admin", new { message = "Ruta agregada correctamente" }));
        }
        public ActionResult Drivers(string message = "", string id = "", string name = "", string lastName = "", string secondLastName = "", string email = "", string password = "", string password2 = "")
        {
            //ScriptManager.RegisterStartupScript(Page, Page.GetType(), "myModal", "$('#myModal').modal();", true);

            ViewData["id"]             = id;
            ViewData["name"]           = name;
            ViewData["lastName"]       = lastName;
            ViewData["secondLastName"] = secondLastName;
            ViewData["email"]          = email;
            ViewData["password"]       = password;
            ViewData["password2"]      = password2;
            ViewBag.Message            = message;
            List <DriversTableViewModel> lst;

            using (SMART_PAYMENT_DBEntities db = new SMART_PAYMENT_DBEntities())
            {
                lst = (from d in db.CHOFERs
                       select new DriversTableViewModel
                {
                    Id = d.CHO_IDENTIFICACION,
                    Email = d.CHO_CORREO_ELECTRONICO,
                    Name = d.CHO_NOMBRE,
                    Lastname = d.CHO_PRIMER_APELLIDO,
                    SecondLastname = d.CHO_SEGUNDO_APELLIDO,
                    State = d.CHO_ESTADO
                }).ToList();
            }
            return(View(lst));
        }
Esempio n. 3
0
        public ActionResult UpdateCoinPurse(string ammount)
        {
            if (string.IsNullOrEmpty(ammount))
            {
                return(RedirectToAction("Index", "Profile", new { message = "Campos en blanco" }));
            }

            if (Decimal.Parse(ammount) > 0)
            {
                SMART_PAYMENT_DBEntities db = new SMART_PAYMENT_DBEntities();

                client = db.CLIENTEs.FirstOrDefault(x => x.CLI_CORREO_ELECTRONICO == System.Web.HttpContext.Current.User.Identity.Name);

                client.CLI_MONEDERO += Decimal.Parse(ammount);

                db.Entry(client).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();

                ViewData["monedero"] = client.CLI_MONEDERO;

                return(RedirectToAction("Index", "Profile"));
            }
            else
            {
                return(RedirectToAction("Index", "Profile", new { message = "Debe ingresar un monto mayor a 0" }));
            }
        }
        public static bool IsRegisteredID(string id)
        {
            SMART_PAYMENT_DBEntities db = new SMART_PAYMENT_DBEntities();

            var chofer = db.CHOFERs.FirstOrDefault(e => e.CHO_IDENTIFICACION == id);

            return((chofer != null) ? true : false);
        }
        public static bool IsRegisteredName(string nombre)
        {
            SMART_PAYMENT_DBEntities db = new SMART_PAYMENT_DBEntities();

            var ruta = db.RUTAs.FirstOrDefault(e => e.RUT_NOMBRE == nombre);

            return((ruta != null) ? true : false);
        }
Esempio n. 6
0
        public static bool IsRegisteredID(string id)
        {
            SMART_PAYMENT_DBEntities db = new SMART_PAYMENT_DBEntities();

            var cliente = db.CLIENTEs.FirstOrDefault(e => e.CLI_IDENTIFICACION == id);

            return((cliente != null) ? true : false);
        }
        public static bool IsRegisteredEmail(string email)
        {
            SMART_PAYMENT_DBEntities db = new SMART_PAYMENT_DBEntities();

            var chofer = db.CHOFERs.FirstOrDefault(e => e.CHO_CORREO_ELECTRONICO == email);

            return((chofer != null) ? true : false);
        }
        public decimal getGanancia()
        {
            decimal gananciaTotal = 0;

            SMART_PAYMENT_DBEntities db = new SMART_PAYMENT_DBEntities();

            chofer = db.CHOFERs.FirstOrDefault(x => x.CHO_CORREO_ELECTRONICO == System.Web.HttpContext.Current.User.Identity.Name);

            List <PaymentsTableViewModel> lstPayment;

            lstPayment = (from d in db.PAGOes
                          select new PaymentsTableViewModel
            {
                Id = d.PAG_ID,
                Id_Client = d.PAG_IDENTIFICACION_CLIENTE,
                Id_Driver = d.PAG_IDENTIFICACION_CHOFER,
                Id_Route = d.PAG_CODIGO_CTP_RUTA,
                DateOfPayment = d.PAG_FECHA,
                State = d.RECHAZADO
            }).ToList();

            List <RoutesTableViewModel> lstRoutes;

            lstRoutes = (from d in db.RUTAs
                         select new RoutesTableViewModel
            {
                Code = d.RUT_CODIGO_CTP,
                Provincia = d.RUT_PROVINCIA,
                Canton = d.RUT_CANTON,
                Nombre = d.RUT_NOMBRE,
                Costo = d.RUT_COSTO,
                State = d.RUT_ESTADO
            }).ToList();

            System.DateTime today = new System.DateTime(System.DateTime.Today.Ticks);
            string          td    = today.ToShortDateString();

            foreach (var payment in lstPayment)
            {
                System.DateTime recordDate = payment.DateOfPayment;
                string          rd         = recordDate.ToShortDateString();

                if (chofer.CHO_IDENTIFICACION.Equals(payment.Id_Driver) && !payment.State && td.Equals(rd))
                {
                    foreach (var route in lstRoutes)
                    {
                        if (payment.Id_Route == route.Code)
                        {
                            gananciaTotal += route.Costo;
                            break;
                        }
                    }
                }
            }

            return(gananciaTotal);
        }
        public ActionResult MakePayment(string cedula, string ruta)
        {
            if (string.IsNullOrEmpty(cedula) || string.IsNullOrEmpty(ruta))
            {
                return(RedirectToAction("Index", new { message = "Campos en blanco", email = currentEmail, cedula = cedula, ruta = ruta }));
            }

            int rutaId = Int32.Parse(ruta);
            SMART_PAYMENT_DBEntities db = new SMART_PAYMENT_DBEntities();

            var client = db.CLIENTEs.FirstOrDefault(x => x.CLI_IDENTIFICACION == cedula);
            var route  = db.RUTAs.FirstOrDefault(x => x.RUT_CODIGO_CTP == rutaId);

            chofer = db.CHOFERs.FirstOrDefault(x => x.CHO_CORREO_ELECTRONICO == System.Web.HttpContext.Current.User.Identity.Name);


            decimal  total = client.CLI_MONEDERO - route.RUT_COSTO;
            DateTime today = System.DateTime.Now;

            var pago = new PAGO();

            pago.PAG_IDENTIFICACION_CLIENTE = client.CLI_IDENTIFICACION;
            pago.PAG_IDENTIFICACION_CHOFER  = chofer.CHO_IDENTIFICACION;
            pago.PAG_CODIGO_CTP_RUTA        = route.RUT_CODIGO_CTP;
            pago.PAG_FECHA = today;
            pago.RECHAZADO = false;


            if (total < 0)
            {
                pago.RECHAZADO = true;

                db.Entry(pago).State = System.Data.Entity.EntityState.Added;
                db.SaveChanges();
                return(RedirectToAction("Index", new { message = "Saldo Insuficiente", email = currentEmail, cedula = cedula, ruta = ruta }));
            }
            else
            {
                client.CLI_MONEDERO    = total;
                db.Entry(client).State = System.Data.Entity.EntityState.Modified;
                db.Entry(pago).State   = System.Data.Entity.EntityState.Added;
                db.SaveChanges();

                return(RedirectToAction("Index", new { message = "Pago Exitoso", email = currentEmail, cedula = cedula, ruta = ruta }));
            }
        }
Esempio n. 10
0
        public ActionResult Clients()
        {
            List <ClientsTableViewModel> lst;

            using (SMART_PAYMENT_DBEntities db = new SMART_PAYMENT_DBEntities())
            {
                lst = (from d in db.CLIENTEs
                       select new ClientsTableViewModel
                {
                    Id = d.CLI_IDENTIFICACION,
                    Email = d.CLI_CORREO_ELECTRONICO,
                    Name = d.CLI_NOMBRE,
                    Lastname = d.CLI_PRIMER_APELLIDO,
                    SecondLastname = d.CLI_SEGUNDO_APELLIDO,
                    State = d.CLI_ESTADO
                }).ToList();
            }
            return(View(lst));
        }
Esempio n. 11
0
        public List <RoutesTableViewModel> GetRoutes()
        {
            List <RoutesTableViewModel> lst;

            using (SMART_PAYMENT_DBEntities db = new SMART_PAYMENT_DBEntities())
            {
                lst = (from d in db.RUTAs
                       select new RoutesTableViewModel
                {
                    Code = d.RUT_CODIGO_CTP,
                    Provincia = d.RUT_PROVINCIA,
                    Canton = d.RUT_CANTON,
                    Nombre = d.RUT_NOMBRE,
                    Costo = d.RUT_COSTO,
                    State = d.RUT_ESTADO
                }).ToList();
            }
            return(lst);
        }
Esempio n. 12
0
        public ActionResult DisableRoute(int id)
        {
            SMART_PAYMENT_DBEntities db = new SMART_PAYMENT_DBEntities();

            var route = db.RUTAs.FirstOrDefault(x => x.RUT_CODIGO_CTP == id);


            if (route.RUT_ESTADO == true)
            {
                route.RUT_ESTADO = false;
            }
            else
            {
                route.RUT_ESTADO = true;
            }

            db.Entry(route).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();

            return(RedirectToAction("Routes", "Admin"));
        }
Esempio n. 13
0
        public ActionResult DisableDriver(string id)
        {
            SMART_PAYMENT_DBEntities db = new SMART_PAYMENT_DBEntities();

            var driver = db.CHOFERs.FirstOrDefault(x => x.CHO_IDENTIFICACION == id);


            if (driver.CHO_ESTADO == true)
            {
                driver.CHO_ESTADO = false;
            }
            else
            {
                driver.CHO_ESTADO = true;
            }

            db.Entry(driver).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();

            return(RedirectToAction("Drivers", "Admin"));
        }
Esempio n. 14
0
        public ActionResult DisableClient(string id)
        {
            SMART_PAYMENT_DBEntities db = new SMART_PAYMENT_DBEntities();

            var client = db.CLIENTEs.FirstOrDefault(x => x.CLI_IDENTIFICACION == id);


            if (client.CLI_ESTADO == true)
            {
                client.CLI_ESTADO = false;
            }
            else
            {
                client.CLI_ESTADO = true;
            }

            db.Entry(client).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();

            return(RedirectToAction("Clients", "Admin"));
        }
Esempio n. 15
0
        public ActionResult GetUsername()
        {
            SMART_PAYMENT_DBEntities db = new SMART_PAYMENT_DBEntities();

            client = db.CLIENTEs.FirstOrDefault(x => x.CLI_CORREO_ELECTRONICO == System.Web.HttpContext.Current.User.Identity.Name);


            string dob = client.CLI_FECHA_NACIMIENTO.ToString("yyyy-MM-dd");


            ViewData["id"]             = client.CLI_IDENTIFICACION;
            ViewData["dateOfBirth"]    = dob;
            ViewData["name"]           = client.CLI_NOMBRE;
            ViewData["lastName"]       = client.CLI_PRIMER_APELLIDO;
            ViewData["secondLastName"] = client.CLI_SEGUNDO_APELLIDO;
            ViewData["paymentMethod"]  = client.CLI_METODO_PAGO;
            ViewData["email"]          = client.CLI_CORREO_ELECTRONICO;
            ViewData["password"]       = client.CLI_CONTRASENNA;
            ViewData["password2"]      = client.CLI_CONTRASENNA;
            ViewData["monedero"]       = client.CLI_MONEDERO;
            return(View());
        }
Esempio n. 16
0
        public List <PaymentsTableViewModel> GetReports()
        {
            SMART_PAYMENT_DBEntities db = new SMART_PAYMENT_DBEntities();

            chofer = db.CHOFERs.FirstOrDefault(x => x.CHO_CORREO_ELECTRONICO == System.Web.HttpContext.Current.User.Identity.Name);

            List <PaymentsTableViewModel> lstPayment;

            lstPayment = (from d in db.PAGOes
                          select new PaymentsTableViewModel
            {
                Id = d.PAG_ID,
                Id_Client = d.PAG_IDENTIFICACION_CLIENTE,
                Id_Driver = d.PAG_IDENTIFICACION_CHOFER,
                Id_Route = d.PAG_CODIGO_CTP_RUTA,
                DateOfPayment = d.PAG_FECHA,
                State = d.RECHAZADO
            }).ToList();



            List <PaymentsTableViewModel> filteredListPayment = new List <PaymentsTableViewModel>();

            foreach (var payment in lstPayment)
            {
                if (chofer.CHO_IDENTIFICACION.Equals(payment.Id_Driver))
                {
                    if (payment.State)
                    {
                        filteredListPayment.Add(payment);
                    }
                }
            }

            return(filteredListPayment);
        }
Esempio n. 17
0
        public ActionResult Routes(string message = "", string provincia = "", string canton = "", string nombre = "", decimal costo = 0)
        {
            ViewData["provincia"] = provincia;
            ViewData["canton"]    = canton;
            ViewData["nombre"]    = nombre;
            ViewData["costo"]     = costo;
            ViewBag.Message       = message;
            List <RoutesTableViewModel> lst;

            using (SMART_PAYMENT_DBEntities db = new SMART_PAYMENT_DBEntities())
            {
                lst = (from d in db.RUTAs
                       select new RoutesTableViewModel
                {
                    Code = d.RUT_CODIGO_CTP,
                    Provincia = d.RUT_PROVINCIA,
                    Canton = d.RUT_CANTON,
                    Nombre = d.RUT_NOMBRE,
                    Costo = d.RUT_COSTO,
                    State = d.RUT_ESTADO
                }).ToList();
            }
            return(View(lst));
        }
Esempio n. 18
0
        public ActionResult AddNewDriver(string id, DateTime dateOfBirth, string name, string lastName, string secondLastName, string email, string password, string password2)
        {
            if (string.IsNullOrEmpty(id) || dateOfBirth == null || string.IsNullOrEmpty(name) || string.IsNullOrEmpty(lastName) || string.IsNullOrEmpty(secondLastName) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(password2))
            {
                return(RedirectToAction("Drivers", "Admin", new { message = "Campos vacíos", id = id, name = name, lastName = lastName, secondLastName = secondLastName, email = email, password = password, password2 = password2 }));
            }

            if (dateOfBirth > DateTime.Today)
            {
                return(RedirectToAction("Drivers", "Admin", new { message = "La fecha de nacimiento no puede ser mayor a la fecha actual", id = id, name = name, lastName = lastName, secondLastName = secondLastName, email = email, password = password, password2 = password2 }));
            }

            if (Int32.Parse(id) <= 0)
            {
                return(RedirectToAction("Drivers", "Admin", new { message = "El número de identificación debe ser mayor a 0", id = id, name = name, lastName = lastName, secondLastName = secondLastName, email = email, password = password, password2 = password2 }));
            }

            if (!IsValidEmailAddress(email.Trim()))
            {
                return(RedirectToAction("Drivers", "Admin", new { message = "Correo electrónico inválido", id = id, name = name, lastName = lastName, secondLastName = secondLastName, email = email, password = password, password2 = password2 }));
            }

            if (string.Equals(password.Trim(), password2.Trim()))
            {
                if (password.Trim().Length < 8)
                {
                    return(RedirectToAction("Drivers", "Admin", new { message = "La longitud de la contraseña debe ser mayor o igual 8", id = id, name = name, lastName = lastName, secondLastName = secondLastName, email = email, password = password, password2 = password2 }));
                }
                else if (!IsValidPassword(password.Trim()))
                {
                    return(RedirectToAction("Drivers", "Admin", new { message = "La contraseña debe contener números y letras", id = id, name = name, lastName = lastName, secondLastName = secondLastName, email = email, password = password, password2 = password2 }));
                }
            }
            else
            {
                return(RedirectToAction("Drivers", "Admin", new { message = "Contraseñas no coinciden", id = id, name = name, lastName = lastName, secondLastName = secondLastName, email = email, password = password, password2 = password2 }));
            }

            if (IsRegisteredID(id.Trim()))
            {
                return(RedirectToAction("Drivers", "Admin", new { message = "Identificación ya se encuentra registrada", id = id, name = name, lastName = lastName, secondLastName = secondLastName, email = email, password = password, password2 = password2 }));
            }


            if (IsRegisteredEmail(email.Trim()))
            {
                return(RedirectToAction("Drivers", "Admin", new { message = "Correo electrónico ya está registrado", id = id, name = name, lastName = lastName, secondLastName = secondLastName, email = email, password = password, password2 = password2 }));
            }

            var chofer = new CHOFER();

            chofer.CHO_IDENTIFICACION     = id.Trim();
            chofer.CHO_FECHA_NACIMIENTO   = dateOfBirth;
            chofer.CHO_NOMBRE             = name.Trim();
            chofer.CHO_PRIMER_APELLIDO    = lastName.Trim();
            chofer.CHO_SEGUNDO_APELLIDO   = secondLastName.Trim();
            chofer.CHO_CORREO_ELECTRONICO = email.Trim();
            chofer.CHO_CONTRASENNA        = password.Trim();
            chofer.CHO_ESTADO             = true;

            SMART_PAYMENT_DBEntities db = new SMART_PAYMENT_DBEntities();

            db.Entry(chofer).State = System.Data.Entity.EntityState.Added;
            db.SaveChanges();

            return(RedirectToAction("Drivers", "Admin", new { message = "Chofer agregado correctamente" }));
        }
Esempio n. 19
0
        public ActionResult Login(string email, string password)
        {
            bool validForm = true;

            if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password))
            {
                validForm = false;
                return(RedirectToAction("Index", new { message = "Campos en blanco", email = email }));
            }
            else if (!IsValidEmailAddress(email.Trim()))
            {
                validForm = false;
                return(RedirectToAction("Index", new { message = "Debe ingresar un correo electrónico válido", email = email }));
            }


            if (validForm)
            {
                SMART_PAYMENT_DBEntities db = new SMART_PAYMENT_DBEntities();

                var cliente = db.CLIENTEs.FirstOrDefault(e => e.CLI_CORREO_ELECTRONICO == email.Trim() && e.CLI_CONTRASENNA == password.Trim());
                var admin   = db.ADMINISTRADORs.FirstOrDefault(e => e.ADM_CORREO_ELECTRONICO == email.Trim() && e.ADM_CONTRASENNA == password.Trim());
                var driver  = db.CHOFERs.FirstOrDefault(e => e.CHO_CORREO_ELECTRONICO == email.Trim() && e.CHO_CONTRASENNA == password.Trim());


                if (cliente != null)
                {
                    if (cliente.CLI_ESTADO == true)
                    {
                        FormsAuthentication.SetAuthCookie(cliente.CLI_CORREO_ELECTRONICO, true);
                        return(RedirectToAction("Index", "Profile"));
                    }
                    else
                    {
                        return(RedirectToAction("Index", new { message = "Cuenta deshabilitada. Por favor contactar al administrador", email = email }));
                    }
                }
                else if (admin != null)
                {
                    FormsAuthentication.SetAuthCookie(admin.ADM_CORREO_ELECTRONICO, true);
                    return(RedirectToAction("Index", "Admin"));
                }
                else if (driver != null)
                {
                    if (driver.CHO_ESTADO == true)
                    {
                        FormsAuthentication.SetAuthCookie(driver.CHO_CORREO_ELECTRONICO, true);
                        return(RedirectToAction("Index", "Driver", new { email = driver.CHO_CORREO_ELECTRONICO }));
                    }
                    else
                    {
                        return(RedirectToAction("Index", new { message = "Cuenta deshabilitada. Por favor contactar al administrador", email = email }));
                    }
                }
                else
                {
                    return(RedirectToAction("Index", new { message = "Correo electrónico y/o contraseña inválidos", email = email }));
                }
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
Esempio n. 20
0
        public ActionResult AddUser(string id, DateTime dateOfBirth, string name, string lastName, string secondLastName, string paymentMethod, string email, string password, string password2)
        {
            bool validForm = true;

            if (string.IsNullOrEmpty(id) || dateOfBirth == null || string.IsNullOrEmpty(name) || string.IsNullOrEmpty(lastName) || string.IsNullOrEmpty(secondLastName) || string.IsNullOrEmpty(paymentMethod) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(password2))
            {
                validForm = false;
                return(RedirectToAction("Register", new { message = "Campos vacíos", id = id, name = name, lastName = lastName, secondLastName = secondLastName, paymentMethod = paymentMethod, email = email, password = password, password2 = password2 }));
            }

            if (dateOfBirth > DateTime.Today)
            {
                validForm = false;
                return(RedirectToAction("Register", new { message = "La fecha de nacimiento no puede ser mayor a la fecha actual", id = id, name = name, lastName = lastName, secondLastName = secondLastName, paymentMethod = paymentMethod, email = email, password = password, password2 = password2 }));
            }

            if (Int32.Parse(id) <= 0)
            {
                validForm = false;
                return(RedirectToAction("Register", new { message = "El número de identificación debe ser mayor a 0", id = id, name = name, lastName = lastName, secondLastName = secondLastName, paymentMethod = paymentMethod, email = email, password = password, password2 = password2 }));
            }

            if (Int32.Parse(paymentMethod) <= 0)
            {
                validForm = false;
                return(RedirectToAction("Register", new { message = "El método de pago debe ser mayor a 0", id = id, name = name, lastName = lastName, secondLastName = secondLastName, paymentMethod = paymentMethod, email = email, password = password, password2 = password2 }));
            }

            if (!IsValidEmailAddress(email.Trim()))
            {
                validForm = false;
                return(RedirectToAction("Register", new { message = "Correo electrónico inválido", id = id, name = name, lastName = lastName, secondLastName = secondLastName, paymentMethod = paymentMethod, email = email, password = password, password2 = password2 }));
            }


            if (string.Equals(password.Trim(), password2.Trim()))
            {
                if (password.Trim().Length < 8)
                {
                    validForm = false;
                    return(RedirectToAction("Register", new { message = "La longitud de la contraseña debe ser mayor o igual 8", id = id, name = name, lastName = lastName, secondLastName = secondLastName, paymentMethod = paymentMethod, email = email, password = password, password2 = password2 }));
                }
                else if (!IsValidPassword(password.Trim()))
                {
                    validForm = false;
                    return(RedirectToAction("Register", new { message = "La contraseña debe contener números y letras", id = id, name = name, lastName = lastName, secondLastName = secondLastName, paymentMethod = paymentMethod, email = email, password = password, password2 = password2 }));
                }
            }
            else
            {
                validForm = false;
                return(RedirectToAction("Register", new { message = "Contraseñas no coinciden", id = id, name = name, lastName = lastName, secondLastName = secondLastName, paymentMethod = paymentMethod, email = email, password = password, password2 = password2 }));
            }

            if (IsRegisteredID(id.Trim()))
            {
                validForm = false;
                return(RedirectToAction("Register", new { message = "Identificación ya se encuentra registrada", id = id, name = name, lastName = lastName, secondLastName = secondLastName, paymentMethod = paymentMethod, email = email, password = password, password2 = password2 }));
            }


            if (IsRegisteredEmail(email.Trim()))
            {
                validForm = false;
                return(RedirectToAction("Register", new { message = "Correo electrónico ya está registrado", id = id, name = name, lastName = lastName, secondLastName = secondLastName, paymentMethod = paymentMethod, email = email, password = password, password2 = password2 }));
            }


            if (validForm)
            {
                var client = new CLIENTE();

                client.CLI_IDENTIFICACION     = id.ToString();
                client.CLI_FECHA_NACIMIENTO   = dateOfBirth;
                client.CLI_NOMBRE             = name.Trim();
                client.CLI_PRIMER_APELLIDO    = lastName.Trim();
                client.CLI_SEGUNDO_APELLIDO   = secondLastName.Trim();
                client.CLI_METODO_PAGO        = paymentMethod.Trim();
                client.CLI_CORREO_ELECTRONICO = email.Trim();
                client.CLI_CONTRASENNA        = password.Trim();
                client.CLI_MONEDERO           = 0;
                client.CLI_ESTADO             = true;

                SMART_PAYMENT_DBEntities db = new SMART_PAYMENT_DBEntities();

                db.Entry(client).State = System.Data.Entity.EntityState.Added;
                db.SaveChanges();

                return(RedirectToAction("Index", "Home", new { message = "Cuenta creada correctamente" }));
            }
            else
            {
                return(RedirectToAction("Register", new { id = id, name = name, lastName = lastName, secondLastName = secondLastName, paymentMethod = paymentMethod, email = email, password = password, password2 = password2 }));
            }
        }
Esempio n. 21
0
        public List <ReportsClientTableVM> GetReports()
        {
            SMART_PAYMENT_DBEntities db = new SMART_PAYMENT_DBEntities();

            client = db.CLIENTEs.FirstOrDefault(x => x.CLI_CORREO_ELECTRONICO == System.Web.HttpContext.Current.User.Identity.Name);



            List <PaymentsTableViewModel> lstPayment;

            lstPayment = (from d in db.PAGOes
                          select new PaymentsTableViewModel
            {
                Id = d.PAG_ID,
                Id_Client = d.PAG_IDENTIFICACION_CLIENTE,
                Id_Driver = d.PAG_IDENTIFICACION_CHOFER,
                Id_Route = d.PAG_CODIGO_CTP_RUTA,
                DateOfPayment = d.PAG_FECHA,
                State = d.RECHAZADO
            }).ToList();

            List <RoutesTableViewModel> lstRoutes;

            lstRoutes = (from d in db.RUTAs
                         select new RoutesTableViewModel
            {
                Code = d.RUT_CODIGO_CTP,
                Provincia = d.RUT_PROVINCIA,
                Canton = d.RUT_CANTON,
                Nombre = d.RUT_NOMBRE,
                Costo = d.RUT_COSTO,
                State = d.RUT_ESTADO
            }).ToList();



            List <PaymentsTableViewModel> filteredListPayment = new List <PaymentsTableViewModel>();
            List <ReportsClientTableVM>   filteredReports     = new List <ReportsClientTableVM>();



            foreach (var payment in lstPayment)
            {
                if (client.CLI_IDENTIFICACION.Equals(payment.Id_Client))
                {
                    ReportsClientTableVM newEntryReport = new ReportsClientTableVM();

                    foreach (var route in lstRoutes)
                    {
                        if (payment.Id_Route == route.Code)
                        {
                            newEntryReport.Id            = payment.Id;
                            newEntryReport.Nombre        = route.Nombre;
                            newEntryReport.Costo         = route.Costo;
                            newEntryReport.DateOfPayment = payment.DateOfPayment;
                            newEntryReport.State         = payment.State;

                            filteredReports.Add(newEntryReport);
                        }
                    }
                }
            }

            return(filteredReports);
        }