Exemple #1
0
        public async Task <IActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var role = "Grower";
                var user = await _userHelper.AddUser(model, role);

                if (user == null)
                {
                    ModelState.AddModelError(string.Empty, "This email is already used.");
                    return(View(model));
                }

                var usergeneric = new Grower
                {
                    Plants = new List <Plant>(),
                    User   = user
                };

                _dataContext.Growers.Add(usergeneric);
                await _dataContext.SaveChangesAsync();

                return(View(model));
            }
            return(View(model));
        }
        public async Task <IActionResult> Register(AddUserViewModel view)
        {
            if (ModelState.IsValid)
            {
                var role = "Owner";
                if (view.RoleId == 1)
                {
                    role = "Lessee";
                }

                var user = await _userHelper.AddUser(view, role);

                if (user == null)
                {
                    ModelState.AddModelError(string.Empty, "This email is already used.");
                    return(View(view));
                }

                if (view.RoleId == 1)
                {
                    var lessee = new Lessee
                    {
                        Contracts = new List <Contract>(),
                        User      = user
                    };

                    _dataContext.Lessees.Add(lessee);
                    await _dataContext.SaveChangesAsync();
                }
                else
                {
                    var owner = new Owner
                    {
                        Contracts  = new List <Contract>(),
                        Properties = new List <Property>(),
                        User       = user
                    };

                    _dataContext.Owners.Add(owner);
                    await _dataContext.SaveChangesAsync();
                }

                var myToken = await _userHelper.GenerateEmailConfirmationTokenAsync(user);

                var tokenLink = Url.Action("ConfirmEmail", "Account", new
                {
                    userid = user.Id,
                    token  = myToken
                }, protocol: HttpContext.Request.Scheme);

                _mailHelper.SendMail(view.Username, "Email confirmation", $"<h1>Email Confirmation</h1>" +
                                     $"To allow the user, " +
                                     $"plase click in this link:</br></br><a href = \"{tokenLink}\">Confirm Email</a>");
                ViewBag.Message = "The instructions to allow your user has been sent to email.";
                return(View(view));
            }

            return(View(view));
        }
Exemple #3
0
        public async Task <IActionResult> Register(AddUserViewModel model)
        {
            if (ModelState.IsValid)
            {
                var role = "Owner";
                if (model.RoleId == 1)
                {
                    role = "Lessee";
                }

                var user = await _userHelper.AddUser(model, role);

                if (user == null)
                {
                    ModelState.AddModelError(string.Empty, "This email is already used.");
                    return(View(model));
                }

                if (model.RoleId == 1)
                {
                    var lessee = new Lessee
                    {
                        Contracts = new List <Contract>(),
                        User      = user
                    };

                    _dataContext.Lessees.Add(lessee);
                }
                else
                {
                    var owner = new Owner
                    {
                        Contracts  = new List <Contract>(),
                        Properties = new List <Property>(),
                        User       = user
                    };

                    _dataContext.Owners.Add(owner);
                }
                await _dataContext.SaveChangesAsync();

                var loginViewModel = new LoginViewModel
                {
                    Password   = model.Password,
                    RememberMe = false,
                    Username   = model.Username
                };

                var result2 = await _userHelper.LoginAsync(loginViewModel);

                if (result2.Succeeded)
                {
                    return(RedirectToAction("Index", "Home"));
                }
            }

            model.Roles = _combosHelper.GetComboRoles();
            return(View(model));
        }
Exemple #4
0
        public async Task <IActionResult> Register(AddUserViewModel view)
        {
            if (ModelState.IsValid)
            {
                var role = "Customer";
                if (view.RoleId == 1)
                {
                    role = "Admin";
                }

                var user = await _userHelper.AddUser(view, role);

                if (user == null)
                {
                    ModelState.AddModelError(string.Empty, "este Email ya ha sido Registrado.");
                    return(View(view));
                }



                var loginViewModel = new LoginViewModel
                {
                    Password   = view.Password,
                    RememberMe = false,
                    Username   = view.Username
                };

                var result2 = await _userHelper.LoginAsync(loginViewModel);

                if (result2.Succeeded)
                {
                    return(RedirectToAction("Index", "Home"));
                }

                /*  Codigo para hacer la validacion por email
                 * var myToken = await _userHelper.GenerateEmailConfirmationTokenAsync(user);
                 *  var tokenLink = Url.Action("ConfirmEmail", "Account", new
                 *  {
                 *      userid = user.Id,
                 *      token = myToken
                 *  }, protocol: HttpContext.Request.Scheme);
                 *
                 *  _mailHelper.SendMail(view.Username, "Email confirmation", $"<h1>Email Confirmation</h1>" +
                 *      $"To allow the user, " +
                 *      $"plase click in this link:</br></br><a href = \"{tokenLink}\">Confirm Email</a>");
                 *  ViewBag.Message = "The instructions to allow your user has been sent to email.";
                 *  return View(view);
                 *
                 *
                 */
            }

            return(View(view));
        }
        public async Task <IActionResult> Register(AddUserViewModel model)
        {
            if (ModelState.IsValid)
            {
                var role = "";
                if (model.RoleId == 1)
                {
                    role = "Patient";
                }

                var user = await _userHelper.AddUser(model, role);

                if (user == null)
                {
                    ModelState.AddModelError(string.Empty, "This email is already used.");
                    return(View(model));
                }

                if (model.RoleId == 1)
                {
                    var patient = new Patient
                    {
                        MedicalOrders = new List <MedicalOrder>(),
                        User          = user
                    };

                    _datacontext.Patients.Add(patient);
                }

                await _datacontext.SaveChangesAsync();

                var myToken = await _userHelper.GenerateEmailConfirmationTokenAsync(user);

                var tokenLink = Url.Action("ConfirmEmail", "Account", new
                {
                    userid = user.Id,
                    token  = myToken
                }, protocol: HttpContext.Request.Scheme);

                _mailHelper.SendMail(model.Username, "MediSegurity - Email confirmation", $"<h1>Email Confirmation</h1>" +
                                     $"To allow the user, " +
                                     $"plase click in this link:</br></br><a href = \"{tokenLink}\">Confirm Email</a>");
                ViewBag.Message = "The instructions to allow your user has been sent to email.";
                return(View(model));
            }

            model.Roles = _combosHelper.GetComboRoles();
            return(View(model));
        }
Exemple #6
0
        public async Task <IActionResult> Create(AddUserViewModel view)
        {
            if (ModelState.IsValid)
            {
                var  role    = "Patient";
                bool canEdit = false;


                if (view.RoleId == 1)
                {
                    role    = "Doctor";
                    canEdit = true;
                }

                var user = await _userHelper.AddUser(view, role, canEdit);

                if (user == null)
                {
                    ModelState.AddModelError(string.Empty, "This email is already used.");
                    return(View(view));
                }

                if (view.RoleId == 1)
                {
                    var doctor = new Doctor
                    {
                        User = user,
                    };
                    _dataContext.Doctors.Add(doctor);
                }
                else
                {
                    var patient = new Patient
                    {
                        User = user,
                    };
                    _dataContext.Patients.Add(patient);
                }

                await _dataContext.SaveChangesAsync();
            }
            return(View(view));
        }
Exemple #7
0
        public async Task <IActionResult> Create(AddUserViewModel view)
        {
            if (ModelState.IsValid)
            {
                if (!Captcha.ValidateCaptchaCode(view.CaptchaCode, HttpContext))
                {
                    ViewBag.danger = "خطا كلمة التحقق غير صحيحة";
                    return(View(view));
                }
                var user = await _userHelper.AddUser(view, "Lessee");

                if (user == null)
                {
                    ModelState.AddModelError(string.Empty, "هذا البريد الإلكتروني مستخدم.");
                    return(View(view));
                }

                var lessee = new Lessee
                {
                    Contracts = new List <Contract>(),
                    User      = user,
                };

                _dataContext.Lessees.Add(lessee);
                await _dataContext.SaveChangesAsync();

                var myToken = await _userHelper.GenerateEmailConfirmationTokenAsync(user);

                var tokenLink = Url.Action("ConfirmEmail", "Account", new
                {
                    userid = user.Id,
                    token  = myToken
                }, protocol: HttpContext.Request.Scheme);

                _mailHelper.SendMail(view.Username, "Email confirmation", $"<h1>Email Confirmation</h1>" +
                                     $"To allow the user, " +
                                     $"plase click in this link:</br></br><a href = \"{tokenLink}\">Confirm Email</a>");

                return(RedirectToAction(nameof(Index)));
            }

            return(View(view));
        }
Exemple #8
0
        public async Task <IActionResult> Register(AddUserDto model)
        {
            if (ModelState.IsValid)
            {
                var user = await _userHelper.AddUser(model);

                if (user == null)
                {
                    ModelState.AddModelError(string.Empty, "El email esta en uso.");
                    return(View(model));
                }

                await _dataContext.SaveChangesAsync();

                ViewBag.Message = "Usuario Regitrado exitosamente";

                return(View());
            }
            return(RedirectToAction("Login", "Login"));
        }
Exemple #9
0
        public async Task <IActionResult> Create(AddUserViewModel view)
        {
            if (ModelState.IsValid)
            {
                var user = await _userHelper.AddUser(view, "Owner");

                if (user == null)
                {
                    ModelState.AddModelError(string.Empty, "This email is already used.");
                    return(View(view));
                }

                var owner = new Owner
                {
                    Properties = new List <Property>(),
                    Contracts  = new List <Contract>(),
                    User       = user,
                };

                _dataContext.Owners.Add(owner);
                await _dataContext.SaveChangesAsync();

                var myToken = await _userHelper.GenerateEmailConfirmationTokenAsync(user);

                var tokenLink = Url.Action("ConfirmEmail", "Account", new
                {
                    userid = user.Id,
                    token  = myToken
                }, protocol: HttpContext.Request.Scheme);

                _mailHelper.SendMail(view.Username, "Email confirmation", $"<h1>Email Confirmation</h1>" +
                                     $"To allow the user, " +
                                     $"plase click in this link:</br></br><a href = \"{tokenLink}\">Confirm Email</a>");

                return(RedirectToAction(nameof(Index)));
            }

            return(View(view));
        }
Exemple #10
0
        public async Task <IActionResult> Create(AddUserViewModel view)
        {
            if (ModelState.IsValid)
            {
                var user = await _userHelper.AddUser(view, "Lessee");

                if (user == null)
                {
                    ModelState.AddModelError(string.Empty, "Este correo ya está registrado.");
                    return(View(view));
                }

                var lessee = new Lessee
                {
                    Contracts = new List <Contract>(),
                    User      = user,
                };

                _dataContext.Lessees.Add(lessee);
                await _dataContext.SaveChangesAsync();

                var myToken = await _userHelper.GenerateEmailConfirmationTokenAsync(user);

                var tokenLink = Url.Action("ConfirmEmail", "Account", new
                {
                    userid = user.Id,
                    token  = myToken
                }, protocol: HttpContext.Request.Scheme);

                _mailHelper.SendMail(view.Username, "Correo de confirmación", $"<h1>Correo de Confirmación</h1>" +
                                     $"Para tener acceso, " +
                                     $"por favor dar clic en el enlace:</br></br><a href = \"{tokenLink}\">Confirmar correo</a>");

                return(RedirectToAction(nameof(Index)));
            }

            return(View(view));
        }
Exemple #11
0
        public async Task <IActionResult> Create(AddUserViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = await _userHelper.AddUser(model, "Manager");

                if (user == null)
                {
                    ModelState.AddModelError(string.Empty, "Este correo ya está registrado.");
                    return(View(model));
                }

                var manager = new Manager {
                    User = user
                };

                _dataContext.Managers.Add(manager);
                await _dataContext.SaveChangesAsync();

                var myToken = await _userHelper.GenerateEmailConfirmationTokenAsync(user);

                var tokenLink = Url.Action("ConfirmEmail", "Account", new
                {
                    userid = user.Id,
                    token  = myToken
                }, protocol: HttpContext.Request.Scheme);

                _mailHelper.SendMail(model.Username, "Confirmación de correo", $"<h1>Correo de confirmación</h1>" +
                                     $"Para permitir el acceso, " +
                                     $"por favor haga clic en este enlace:</br></br><a href = \"{tokenLink}\">Confirmar Correo</a>");

                return(RedirectToAction(nameof(Index)));
            }

            return(View(model));
        }
Exemple #12
0
        public async Task <IActionResult> Register(AddUserViewModel model)
        {
            if (ModelState.IsValid)
            {
                var role = "Owner";
                if (model.RoleId == 1)
                {
                    role = "Lessee";
                }

                var user = await _userHelper.AddUser(model, role);

                if (user == null)
                {
                    ModelState.AddModelError(string.Empty, "Este correo ya está en uso.");
                    return(View(model));
                }

                if (model.RoleId == 1)
                {
                    var lessee = new Lessee
                    {
                        Contracts = new List <Contract>(),
                        User      = user
                    };

                    _dataContext.Lessees.Add(lessee);
                }
                else
                {
                    var owner = new Owner
                    {
                        Contracts  = new List <Contract>(),
                        Properties = new List <Property>(),
                        User       = user
                    };

                    _dataContext.Owners.Add(owner);
                }

                await _dataContext.SaveChangesAsync();

                //var loginViewModel = new LoginViewModel
                //{
                //    Password = model.Password,
                //    RememberMe = false,
                //    Username = model.Username
                //};

                //var result2 = await _userHelper.LoginAsync(loginViewModel);

                //if (result2.Succeeded)
                //{
                //    return RedirectToAction("Index", "Home");
                //}
                var myToken = await _userHelper.GenerateEmailConfirmationTokenAsync(user);

                var tokenLink = Url.Action("ConfirmEmail", "Account", new
                {
                    userid = user.Id,
                    token  = myToken
                }, protocol: HttpContext.Request.Scheme);

                _mailHelper.SendMail(model.Username, "Correo de confirmación", $"<h1>Confirmación de correo</h1>" +
                                     $"Para permitir el acceso, " +
                                     $"por favor haga clic en este enlace:</br></br><a href = \"{tokenLink}\">Confirmar Correo</a>");
                ViewBag.Message = "Las instrucciones para acceder al sistema, han sido enviadas al correo.";
                return(View(model));
            }

            model.Roles = _combosHelper.GetComboRoles();
            return(View(model));
        }
        public async Task <IActionResult> Register(AddUserViewModel model)
        {
            if (ModelState.IsValid)
            {
                var role = "Owner";
                if (model.RoleId == 1)
                {
                    role = "Lessee";
                }

                var user = await _userHelper.AddUser(model, role);

                if (user == null)
                {
                    ModelState.AddModelError(string.Empty, "This email is already used.");
                    return(View(model));
                }

                if (model.RoleId == 1)
                {
                    var lessee = new Lessee
                    {
                        Contracts = new List <Contract>(),
                        User      = user
                    };

                    _dataContext.Lessees.Add(lessee);
                }
                else
                {
                    var owner = new Owner
                    {
                        Contracts  = new List <Contract>(),
                        Properties = new List <Property>(),
                        User       = user
                    };

                    _dataContext.Owners.Add(owner);
                    await _dataContext.SaveChangesAsync();
                }

                await _dataContext.SaveChangesAsync();

                var myToken = await _userHelper.GenerateEmailConfirmationTokenAsync(user);

                var tokenLink = Url.Action("ConfirmEmail", "Account", new
                {
                    userid = user.Id,
                    token  = myToken
                }, protocol: HttpContext.Request.Scheme);

                /*
                 * _mailHelper.SendMail(view.Username, "Email confirmation", $"<h1>Email Confirmation</h1>" +
                 *      $"To allow the user, " +
                 *      $"plase click in this link:</br></br><a href = \"{tokenLink}\">Confirm Email</a>");
                 */

                _mailHelper.SendMail(model.Username, "Email confirmation",
                                     $"<table style = 'max-width: 600px; padding: 10px; margin:0 auto; border-collapse: collapse;'>" +
                                     $"  <tr>" +
                                     $"    <td style = 'background-color: #34495e; text-align: center; padding: 0'>" +
                                     $"       <a href = 'https://www.facebook.com/NuskeCIV/' >" +
                                     $"         <img width = '20%' style = 'display:block; margin: 1.5% 3%' src= 'https://veterinarianuske.com/wp-content/uploads/2016/10/line_separator.png'>" +
                                     $"       </a>" +
                                     $"  </td>" +
                                     $"  </tr>" +
                                     $"  <tr>" +
                                     $"  <td style = 'padding: 0'>" +
                                     $"     <img style = 'padding: 0; display: block' src = 'https://veterinarianuske.com/wp-content/uploads/2018/07/logo-nnske-blanck.jpg' width = '100%'>" +
                                     $"  </td>" +
                                     $"</tr>" +
                                     $"<tr>" +
                                     $" <td style = 'background-color: #ecf0f1'>" +
                                     $"      <div style = 'color: #34495e; margin: 4% 10% 2%; text-align: justify;font-family: sans-serif'>" +
                                     $"            <h1 style = 'color: #e67e22; margin: 0 0 7px' > Hola </h1>" +
                                     $"                    <p style = 'margin: 2px; font-size: 15px'>" +
                                     $"                      El mejor Hospital Veterinario Especializado de la Ciudad de Morelia enfocado a brindar servicios médicos y quirúrgicos<br>" +
                                     $"                      aplicando las técnicas más actuales y equipo de vanguardia para diagnósticos precisos y tratamientos oportunos..<br>" +
                                     $"                      Entre los servicios tenemos:</p>" +
                                     $"      <ul style = 'font-size: 15px;  margin: 10px 0'>" +
                                     $"        <li> Urgencias.</li>" +
                                     $"        <li> Medicina Interna.</li>" +
                                     $"        <li> Imagenologia.</li>" +
                                     $"        <li> Pruebas de laboratorio y gabinete.</li>" +
                                     $"        <li> Estetica canina.</li>" +
                                     $"      </ul>" +
                                     $"  <div style = 'width: 100%;margin:20px 0; display: inline-block;text-align: center'>" +
                                     $"    <img style = 'padding: 0; width: 200px; margin: 5px' src = 'https://veterinarianuske.com/wp-content/uploads/2018/07/tarjetas.png'>" +
                                     $"  </div>" +
                                     $"  <div style = 'width: 100%; text-align: center'>" +
                                     $"    <h2 style = 'color: #e67e22; margin: 0 0 7px' >Email Confirmation </h2>" +
                                     $"    To allow the user,plase click in this link:</ br ></ br > " +
                                     $"    <a style ='text-decoration: none; border-radius: 5px; padding: 11px 23px; color: white; background-color: #3498db' href = \"{tokenLink}\">Confirm Email</a>" +
                                     $"    <p style = 'color: #b3b3b3; font-size: 12px; text-align: center;margin: 30px 0 0' > Nuskë Clinica Integral Veterinaria 2019 </p>" +
                                     $"  </div>" +
                                     $" </td >" +
                                     $"</tr>" +
                                     $"</table>");


                ViewBag.Message = "The instructions to allow your user has been sent to email.";
                return(View(model));
            }

            model.Roles = _combosHelper.GetComboRoles();
            return(View(model));
        }
Exemple #14
0
        public async Task <IActionResult> Register(AddUserViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (!Captcha.ValidateCaptchaCode(model.CaptchaCode, HttpContext))
                {
                    ViewBag.danger = "خطا كلمة التحقق غير صحيحة";
                    model.Roles    = _combosHelper.GetComboRoles();
                    return(View(model));
                }
                var role = "Owner";
                if (model.RoleId == 1)
                {
                    role = "Lessee";
                }

                var user = await _userHelper.AddUser(model, role);

                if (user == null)
                {
                    ModelState.AddModelError(string.Empty, "هذا البريد الإلكتروني مستخدم.");
                    model.Roles = _combosHelper.GetComboRoles();
                    return(View(model));
                }

                if (model.RoleId == 1)
                {
                    var lessee = new Lessee
                    {
                        Contracts = new List <Contract>(),
                        User      = user
                    };

                    _dataContext.Lessees.Add(lessee);
                }
                else
                {
                    var owner = new Owner
                    {
                        Contracts  = new List <Contract>(),
                        Properties = new List <Property>(),
                        User       = user
                    };

                    _dataContext.Owners.Add(owner);
                }

                await _dataContext.SaveChangesAsync();

                var myToken = await _userHelper.GenerateEmailConfirmationTokenAsync(user);

                var tokenLink = Url.Action("ConfirmEmail", "Account", new
                {
                    userid = user.Id,
                    token  = myToken
                }, protocol: HttpContext.Request.Scheme);

                _mailHelper.SendMail(model.Username, "تاكيد البريد", $"<h1>تاكيد بريدك الالكتروني</h1>" +
                                     $"لتفعيل حسابك, " +
                                     $"الرجاء الضغط على الرابط التالي:</br></br><a href = \"{tokenLink}\">رابط تاكيد الحساب</a>");

                ViewBag.Message = "تم إرسال تاكيد البريد الالكتروني للمستخدم الى البريد الإلكتروني.";
                model.Roles     = _combosHelper.GetComboRoles();
                return(View(model));
            }

            model.Roles = _combosHelper.GetComboRoles();
            return(View(model));
        }
        public async Task <IActionResult> Register(AddUserViewModel model)
        {
            if (ModelState.IsValid)
            {
                var role = "Owner";
                if (model.RoleId == 1)
                {
                    role = "Lessee";
                }

                var user = await _userHelper.AddUser(model, role);

                if (user == null)
                {
                    ModelState.AddModelError(string.Empty, "This email is already used.");
                    return(View(model));
                }

                if (model.RoleId == 1)
                {
                    var lessee = new Lessee
                    {
                        Contracts = new List <Contract>(),
                        User      = user
                    };

                    _dataContext.Lessees.Add(lessee);
                }
                else
                {
                    var owner = new Owner
                    {
                        Contracts  = new List <Contract>(),
                        Properties = new List <Property>(),
                        User       = user
                    };

                    _dataContext.Owners.Add(owner);
                }

                await _dataContext.SaveChangesAsync();

                //var loginViewModel = new LoginViewModel
                //{
                //    Password = model.Password,
                //    RememberMe = false,
                //    Username = model.Username
                //};

                //var result2 = await _userHelper.LoginAsync(loginViewModel);

                //if (result2.Succeeded)
                //{
                //    return RedirectToAction("Index", "Home");
                //}

                var myToken = await _userHelper.GenerateEmailConfirmationTokenAsync(user);

                var tokenLink = Url.Action("ConfirmEmail", "Account", new
                {
                    userid = user.Id,
                    token  = myToken
                }, protocol: HttpContext.Request.Scheme);

                _mailHelper.SendMail(model.Username, "My Leasing - Email confirmation", $"<h1>My Leasing - Email Confirmation</h1>" +
                                     $"To allow the user, " +
                                     $"plase click in this link:</br></br><a href = \"{tokenLink}\">Confirm Email</a>");
                ViewBag.Message = "The instructions to allow your user has been sent to email.";
                return(View(model));
            }

            model.Roles = _combosHelper.GetComboRoles();
            return(View(model));
        }
Exemple #16
0
        public async Task <IActionResult> Register(AddUserViewModel model)
        {
            if (ModelState.IsValid)
            {
                var role = "Owner";
                if (model.RoleId == 1)
                {
                    role = "Lessee";
                }

                var user = await _userHelper.AddUser(model, role);

                if (user == null)
                {
                    ModelState.AddModelError(string.Empty, "This email is already used.");
                    return(View(model));
                }

                if (model.RoleId == 1)
                {
                    var lessee = new Lessee
                    {
                        Contracts = new List <Contract>(),
                        User      = user
                    };

                    _dataContext.Lessees.Add(lessee);
                }
                else
                {
                    var owner = new Owner
                    {
                        Contracts  = new List <Contract>(),
                        Properties = new List <Property>(),
                        User       = user
                    };

                    _dataContext.Owners.Add(owner);
                }

                await _dataContext.SaveChangesAsync();

                var myToken = await _userHelper.GenerateEmailConfirmationTokenAsync(user);

                var tokenLink = Url.Action("ConfirmEmail", "Account", new
                {
                    userid = user.Id,
                    token  = myToken
                }, protocol: HttpContext.Request.Scheme);
                _mailHelper.SendMail(model.Username, "Email confirmation",
                                     $"<table style = 'max-width: 600px; padding: 10px; margin:0 auto; border-collapse: collapse;'>" +
                                     $"  <tr>" +
                                     $"    <td style = 'background-color: #34495e; text-align: center; padding: 0'>" +
                                     $"       <a href = 'https://www.facebook.com/NuskeCIV/' >" +
                                     $"         <img width = '20%' style = 'display:block; margin: 1.5% 3%' src= 'https://veterinarianuske.com/wp-content/uploads/2016/10/line_separator.png'>" +
                                     $"       </a>" +
                                     $"  </td>" +
                                     $"  </tr>" +
                                     $"  <tr>" +
                                     $"  <td style = 'padding: 0'>" +
                                     $"     <img style = 'padding: 0; display: block' src = 'http://www2.acop.cl/wp-content/uploads/property-leasing-553x300.png' width = '100%'>" +
                                     $"  </td>" +
                                     $"</tr>" +
                                     $"<tr>" +
                                     $" <td style = 'background-color: #ecf0f1'>" +
                                     $"      <div style = 'color: #34495e; margin: 4% 10% 2%; text-align: justify;font-family: sans-serif'>" +
                                     $"            <h1 style = 'color: #e67e22; margin: 0 0 7px' > Hola </h1>" +
                                     $"                    <p style = 'margin: 2px; font-size: 15px'>" +
                                     $"                      El mejor consorcio de arrendamiento Especializado de la Ciudad de Pasto enfocado a brindar servicios Arrendamiento y Venta de inmuebles<br>" +
                                     $"                      nace con la misión de satisfacer las necesidades de vivienda de los habitantes del Área metropolitana. Por más de 30 años hemos concentrado nuestros esfuerzos en garantizar a nuestros clientes un servicio integral ...<br>" +
                                     $"                      Entre los servicios tenemos:</p>" +
                                     $"      <ul style = 'font-size: 15px;  margin: 10px 0'>" +
                                     $"        <li> Arriendo inmueble Nuevo o usado.</li>" +
                                     $"        <li> Venta inmueble Nuevo o usado.</li>" +
                                     $"        <li> Oferta vacacional.</li>" +
                                     $"        <li> Gestion personal</li>" +
                                     $"        <li> Gestion empresarial.</li>" +
                                     $"      </ul>" +
                                     $"  <div style = 'width: 100%;margin:20px 0; display: inline-block;text-align: center'>" +
                                     $"    <img style = 'padding: 0; width: 200px; margin: 5px' src = 'https://veterinarianuske.com/wp-content/uploads/2018/07/tarjetas.png'>" +
                                     $"  </div>" +
                                     $"  <div style = 'width: 100%; text-align: center'>" +
                                     $"    <h2 style = 'color: #e67e22; margin: 0 0 7px' >Email Confirmation </h2>" +
                                     $"    To allow the user,plase click in this link:</br ></br> " +
                                     $"    <a style ='text-decoration: none; border-radius: 5px; padding: 11px 23px; color: white; background-color: #3498db' href = \"{tokenLink}\">Confirm Email</a>" +
                                     $"    <p style = 'color: #b3b3b3; font-size: 12px; text-align: center;margin: 30px 0 0' > LeasingWeb 2019 </p>" +
                                     $"  </div>" +
                                     $" </td >" +
                                     $"</tr>" +
                                     $"</table>");

                ViewBag.Message = "The instructions to allow your user has been sent to email.";
                return(View(model));
            }
            model.Roles = _combosHelper.GetComboRoles();
            return(View(model));
        }
Exemple #17
0
        public async Task <IActionResult> Register(AddUserViewModel model)
        {
            if (ModelState.IsValid)
            {
                var role = "Owner";
                if (model.RoleId == 1)
                {
                    role = "Lessee";
                }

                var user = await _userHelper.AddUser(model, role);

                if (user == null)
                {
                    ModelState.AddModelError(string.Empty, "This email is already used.");
                    return(View(model));
                }

                if (model.RoleId == 1)
                {
                    var lessee = new Lessee
                    {
                        Contracts = new List <Contract>(),
                        User      = user
                    };

                    _dataContext.Lessees.Add(lessee);
                }
                else
                {
                    var owner = new Owner
                    {
                        Contracts  = new List <Contract>(),
                        Properties = new List <Property>(),
                        User       = user
                    };

                    _dataContext.Owners.Add(owner);
                }

                await _dataContext.SaveChangesAsync();

                var myToken = await _userHelper.GenerateEmailConfirmationTokenAsync(user);

                var tokenLink = Url.Action("ConfirmEmail", "Account", new
                {
                    userid = user.Id,
                    token  = myToken
                }, protocol: HttpContext.Request.Scheme);

                _mailHelper.SendMail(model.Username, "Email confirmation",
                                     $"<table style = 'max-width: 600px; padding: 10px; margin:0 auto; border-collapse: collapse;'>" +
                                     $"  <tr>" +
                                     $"    <td style = 'background-color: #34495e; text-align: center; padding: 0'>" +
                                     $"       <a href = '' >" +
                                     $"         <img width = '20%' style = 'display:block; margin: 1.5% 3%' src= ''>" +
                                     $"       </a>" +
                                     $"  </td>" +
                                     $"  </tr>" +
                                     $"  <tr>" +
                                     $"  <td style = 'padding: 0'>" +
                                     $"     <img style = 'padding: 0; display: block' src = '' width = '100%'>" +
                                     $"  </td>" +
                                     $"</tr>" +
                                     $"<tr>" +
                                     $" <td style = 'background-color: #ecf0f1'>" +
                                     $"      <div style = 'color: #34495e; margin: 4% 10% 2%; text-align: justify;font-family: sans-serif'>" +
                                     $"            <h1 style = 'color: #e67e22; margin: 0 0 7px' > Hola </h1>" +
                                     $"                    <p style = 'margin: 2px; font-size: 15px'>" +
                                     $"                      The best specialized leasing agency, focused on providing property leasing services.<br>" +
                                     $"                      We provide all the necessary advice to ensure the best options for owners and renters.<br>" +
                                     $"                      Among the services we have:</p>" +
                                     $"      <ul style = 'font-size: 15px;  margin: 10px 0'>" +
                                     $"        <li> property management.</li>" +
                                     $"        <li> contract administration.</li>" +
                                     $"        <li> property photographs.</li>" +
                                     $"        <li> secure application.</li>" +
                                     $"      </ul>" +
                                     $"  <div style = 'width: 100%;margin:20px 0; display: inline-block;text-align: center'>" +
                                     $"    <img style = 'padding: 0; width: 200px; margin: 5px' src = ''>" +
                                     $"  </div>" +
                                     $"  <div style = 'width: 100%; text-align: center'>" +
                                     $"    <h2 style = 'color: #e67e22; margin: 0 0 7px' >Email Confirmation </h2>" +
                                     $"    To allow the user,plase click in this link:</ br ></ br > " +
                                     $"    <a style ='text-decoration: none; border-radius: 5px; padding: 11px 23px; color: white; background-color: #3498db' href = \"{tokenLink}\">Confirm Email</a>" +
                                     $"    <p style = 'color: #b3b3b3; font-size: 12px; text-align: center;margin: 30px 0 0' > Nuskë Clinica Integral Veterinaria 2019 </p>" +
                                     $"  </div>" +
                                     $" </td >" +
                                     $"</tr>" +
                                     $"</table>");

                ViewBag.Message = "The instructions to allow your user has been sent to email.";
                return(View(model));
            }

            model.Roles = _combosHelper.GetComboRoles();
            return(View(model));
        }
Exemple #18
0
        public ActionResult SaveUser(UserMasterDto userMasterDto)
        {
            _iUserHelper.AddUser(userMasterDto);

            return(RedirectToAction("GetUsers"));
        }
        public async Task <IActionResult> Register(AddUserViewModel model)
        {
            if (ModelState.IsValid)
            {
                var role = "Technical";
                if (model.RoleId == 1)
                {
                    role = "Company";
                }

                var user = await _userHelper.AddUser(model, role);

                if (user == null)
                {
                    ModelState.AddModelError(string.Empty, "Este Email ya está en uso.");
                    return(View(model));
                }

                if (model.RoleId == 1)
                {
                    var company = new Company
                    {
                        //Contracts = new List<Contract>(),
                        User = user
                    };

                    _dataContext.Companies.Add(company);
                }
                else
                {
                    var technical = new Technical
                    {
                        //VisitDetails = new List<VisitDetail>(),
                        Visits = new List <Visit>(),
                        User   = user
                    };

                    _dataContext.Technicals.Add(technical);
                }
                await _dataContext.SaveChangesAsync();

                //var loginViewModel = new LoginViewModel
                //{
                //    Password = model.Password,
                //    RememberMe = false,
                //    Username = model.Username
                //};

                //var result2 = await _userHelper.LoginAsync(loginViewModel);

                //if (result2.Succeeded)
                //{
                //    return RedirectToAction("Index", "Home");
                //}
                var myToken = await _userHelper.GenerateEmailConfirmationTokenAsync(user);

                var tokenLink = Url.Action("ConfirmEmail", "Account", new
                {
                    userid = user.Id,
                    token  = myToken
                }, protocol: HttpContext.Request.Scheme);

                _mailHelper.SendMail(model.Username, "MyApp - Email confirmation", $"<h1>MyApp - Email Confirmation</h1>" +
                                     $"Para permitir el Usuario, " +
                                     $"por favor haga clic en este link:</br></br><a href = \"{tokenLink}\">Confirm Email</a>");
                ViewBag.Message = "Las instrucciones para habilitar su usuario han sido enviadas por mail.";
                return(View(model));
            }
            model.Roles = _combosHelper.GetComboRoles();
            return(View(model));
        }
        public async Task <IActionResult> Register(AddUserViewModel model)
        {
            if (ModelState.IsValid)
            {
                var modelr = new AddUserViewModel
                {
                    Document    = model.Document,
                    FirstName   = model.FirstName,
                    LastName    = model.LastName,
                    PhoneNumber = model.PhoneNumber,
                    Gender      = model.Gender
                };

                var role = "turista";

                var user = await _userHelper.AddUser(model, role);

                if (user == null)
                {
                    ModelState.AddModelError(string.Empty, "Este email ya esta registrado.");
                    return(View(modelr));
                }

                var turista = new Tourist
                {
                    user = user
                };

                _dataContext.Tourists.Add(turista);

                await _dataContext.SaveChangesAsync();

                var myToken = await _userHelper.GenerateEmailConfirmationTokenAsync(user);

                var tokenLink = Url.Action("ConfirmEmail", "Account", new
                {
                    userid = user.Id,
                    token  = myToken
                }, protocol: HttpContext.Request.Scheme);

                _mailHelper.SendMail(model.Username, "Email de confirmación  Tropical beach",
                                     $"<table style = 'max-width: 600px; padding: 10px; margin:0 auto; border-collapse: collapse;'>" +
                                     $"  <tr>" +
                                     $"    <td style = 'background-color: #34495e; text-align: center; padding: 0'>" +
                                     $"       <a href = 'https://www.facebook.com' >" +
                                     $"    Bienvenido" +
                                     $"   </a>" +
                                     $"  </td>" +
                                     $"  </tr>" +
                                     $"  <tr>" +
                                     $"  </tr>" +
                                     $"<tr>" +
                                     $" <td style = 'background-color: #ecf0f1'>" +
                                     $"      <div style = 'color: #34495e; margin: 4% 10% 2%; text-align: justify;font-family: sans-serif'>" +
                                     $"            <h1 style = 'color: #e67e22; margin: 0 0 7px' > Hola " + model.FirstName + " </h1>" +
                                     $"                    <p style = 'margin: 2px; font-size: 15px'>" +
                                     $"Bienvenido a nuestra pagina, este es un mensaje de confirmación, esperamos que disfrutes nuestro Resort                     " +
                                     $" Estaremos atentos a tus inquietudes e inconvenientes." +
                                     $"Nuestros servicios:" +
                                     $"</p>" +
                                     $"      <ul style = 'font-size: 15px;  margin: 10px 0'>" +
                                     $"        <li> Alquiler de habitaciones.</li>" +
                                     $"        <li> Alquiler de cabañas.</li>" +
                                     $"        </ul>" +
                                     $"  <div style = 'width: 100%;margin:20px 0; display: inline-block;text-align: center'>" +
                                     $"    <img style = 'padding: 0; width: 200px; margin: 5px' src = 'https://veterinarianuske.com/wp-content/uploads/2018/07/tarjetas.png'>" +
                                     $"  </div>" +
                                     $"  <div style = 'width: 100%; text-align: center'>" +
                                     $"    <h2 style = 'color: #e67e22; margin: 0 0 7px' >Confirmación de email </h2>" +
                                     $"    Para verificar tu cuenta por favor dar click en el siguiente link:</ br ></ br > " +
                                     $"    <a style ='text-decoration: none; border-radius: 5px; padding: 11px 23px; color: white; background-color: #3498db' href = \"{tokenLink}\">Confirmar Email</a>" +
                                     $"    <p style = 'color: #b3b3b3; font-size: 12px; text-align: center;margin: 30px 0 0' > Concesionario Chevrolet </p>" +
                                     $"  </div>" +
                                     $" </td >" +
                                     $"</tr>" +
                                     $"</table>");

                ViewBag.Message = "Se ha enviado un correo de confirmación.";
                return(View(model));
            }

            return(View(model));
        }