예제 #1
0
        public ActionResult Create()
        {
            Role r1 = new Role();
            r1.RoleId = 13;
            r1.RoleName = "User";

            Role r2 = new Role();
            r2.RoleId = 14;
            r2.RoleName = "Admin";

            List<Role> option = new List<Role>();
            option.Add(r1);
            option.Add(r2);

            ViewBag.Role = new SelectList(option, "RoleId", " RoleName");

            //return View(new  User
            //{
            //    Gender = true
            //});

            return View();
        }
예제 #2
0
        /// <summary>
        /// palak
        /// check  for registrations
        /// </summary>
        /// <param name="u"></param>
        /// <returns></returns>
        public ActionResult Create(User u)
        {
            var list = um.GetAll();
            if (list.Contains(list.FirstOrDefault(q => q.MailId == u.MailId && q.FirstName == null)))
            {
               ViewBag. ErrorMessage = "You are already registered";
                return View();
            }
            Role r1 = new Role();
            r1.RoleId = 13;
            r1.RoleName = "User";

            Role r2 = new Role();
            r2.RoleId = 14;
            r2.RoleName = "Admin";

            List<Role> option = new List<Role>();
            option.Add(r1);
            option.Add(r2);
            ViewBag.Role = new SelectList(option, "RoleId", " RoleName");

            u.RegistrationDate = DateTime.Now;
            um.saveUser(u);

            //mail method
            int id = um.GetAll().Max(a => a.UserId);
            Email mail = new Email();
            mail.FromAddress = "*****@*****.**";
            mail.ToAddress = u.MailId;
            mail.Subject = "Thank you for registration";
            mail.Body = "Hi" + u.MailId + "Thank you for registering at Right to Live./nYour account will be validated once you log in by clicking on this link or copying and pasting it in your browser:/http://localhost:31780/User/Edit/" + Convert.ToString(id) + "This is a one-time login, so it can be used only once./n/nHave a great day,/nRight to Live Team";
            if (es.SendMail(mail))
            {
                //ViewBag.Message = "Registration Success,a link is sent to your Email Id";
                return View("RegistrationSuccess");
            }
            else
            {
                ViewBag.ErrorMessage = "Sorry,We are unable to connect to the Network";
                return View();
            }
        }