Exemplo n.º 1
0
        public ActionResult Ingreso(string nombreing, string primerapeing, string segundoapeing, string telefonoing, string usuarioing,
                                    string passing)
        {
            string idInstructorString;

            instructorBLL = new InstructorBLLImp();
            usuarioBLL    = new LogUsuarioBLLImp();

            idInstructorString = fb.ConsecutivoModifica("INS");

            LogUsuario lu = new LogUsuario()
            {
                usuario         = usuarioing,
                pass            = fb.Encripta(passing),
                idNombreEmpresa = (string)Session["empresa"],
                permiso         = "Instructor"
            };
            InstructorGym ins = new InstructorGym()
            {
                idInstructor    = idInstructorString,
                nombre          = nombreing,
                apellido1       = primerapeing,
                apellido2       = segundoapeing,
                telefono        = telefonoing,
                usuario         = usuarioing,
                idNombreEmpresa = (string)Session["empresa"]
            };

            usuarioBLL.Agregar(lu);
            instructorBLL.Agregar(ins);
            return(Json(new { result = string.Empty }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        public ActionResult Ingreso(string usuarioing, string contrasenaing, string rol, string emailIn)
        {
            usuariosBLL = new LogUsuarioBLLImp();

            LogUsuario per = new LogUsuario
            {
                usuario         = usuarioing,
                pass            = fb.Encripta(contrasenaing),
                idNombreEmpresa = (string)Session["empresa"],
                permiso         = rol
            };
            bool a = usuariosBLL.Agregar(per);

            if (a)
            {
                try
                {
                    using (MailMessage mail = new MailMessage())
                    {
                        mail.From = new MailAddress("*****@*****.**");
                        mail.To.Add(emailIn);
                        mail.Subject    = "Usuario de Ragnarok";
                        mail.Body       = string.Format("{0}:{1}", usuarioing, contrasenaing);
                        mail.IsBodyHtml = true;
                        SmtpClient smtp = new SmtpClient
                        {
                            Host                  = "smtp.gmail.com",
                            Port                  = 587,
                            EnableSsl             = true,
                            DeliveryMethod        = SmtpDeliveryMethod.Network,
                            UseDefaultCredentials = false,
                            Credentials           = new NetworkCredential("*****@*****.**", ""),
                            Timeout               = 20000
                        };
                        smtp.Send(mail);
                        return(Json(new { bol = true }, JsonRequestBehavior.AllowGet));
                    }
                }
                catch (Exception e)
                {
                    string aa = e.Message;
                    return(Json(new { bol = false }, JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                return(Json(new { bol = a }, JsonRequestBehavior.AllowGet));
            }
        }