Esempio n. 1
0
        public ActionResult Login(UserRegVM obj)
        {
            var userdetails = (from context in db.UserRegistrations
                               join sub in db.UserProfiles on context.UserID equals sub.UserID
                               where sub.MyAppID.ToUpper() == obj.MyAppId.ToUpper() &&
                               context.Password == obj.Password
                               select new
            {
                Email = context.Email,
                IsActive = context.IsActive,
                MyappId = sub.MyAppID,
                UserID = sub.UserID,
                Name = context.FirstName + context.LastName,
                Phone = context.Mobile
            }).FirstOrDefault();



            if (userdetails != null && userdetails.IsActive == true)
            {
                FormsAuthentication.SetAuthCookie(userdetails.MyappId, true);
                Session["IsAuthenticated"] = true;
                Session["UserID"]          = userdetails.UserID;
                Session["Email"]           = userdetails.Email;
                Session["Phone"]           = userdetails.Phone;
                Session["Role"]            = "User";
                Session["FirstName"]       = userdetails.Name;

                return(RedirectToAction("ViewProfile", "Profile"));
            }
            else if (userdetails != null && userdetails.IsActive == false)
            {
                //     ModelState.AddModelError("ErrMsg", "Your Account is Not Activated Yet. Please Contact Support Team.");
                //    return View(obj);

                Session["MyAppId"]   = userdetails.MyappId;
                Session["UserID"]    = userdetails.UserID;
                Session["Email"]     = userdetails.Email;
                Session["Phone"]     = userdetails.Phone;
                Session["Role"]      = "User";
                Session["FirstName"] = userdetails.Name;
                return(RedirectToAction("LandingPage"));
            }
            else
            {
                ModelState.AddModelError("ErrMsg", "Invalid Credentials");
                return(View(obj));
            }
        }
Esempio n. 2
0
        public ActionResult Register(UserRegVM obj)
        {
            if (string.IsNullOrEmpty(obj.Password))
            {
                ModelState.AddModelError("Password", "Please Enter Password");
            }

            if (obj.Password != obj.ConfPassword)
            {
                ModelState.AddModelError("ConfPassword", "Password Do Not Match");
            }

            if (!obj.TermsAndConditions)
            {
                ModelState.AddModelError("TermsAndConditions", "Please Select Terms & Conditions Box");
            }

            bool em = db.UserRegistrations.Any(x => x.Email == obj.Email);

            if (em == true)
            {
                ModelState.AddModelError("Email", "Email Already Used");
            }

            if (ModelState.IsValid)
            {
                try
                {
                    UserRegistration o = new UserRegistration();
                    o.Email      = obj.Email;
                    o.Password   = obj.Password;
                    o.Mobile     = obj.Mobile;
                    o.FirstName  = obj.FirstName;
                    o.MiddleName = obj.MiddleName;
                    o.LastName   = obj.LastName;

                    o.IsActive  = false;
                    o.CreatedOn = DateTime.Now;
                    db.UserRegistrations.Add(o);
                    db.SaveChanges();

                    UserProfile oUserProfile = new UserProfile();
                    oUserProfile.Gender = obj.Gender;
                    oUserProfile.UserID = o.UserID;

                    if (oUserProfile.Gender == 1)
                    {
                        oUserProfile.MyAppID = "SAAJB" + o.UserID;
                    }
                    else if (oUserProfile.Gender == 2)
                    {
                        oUserProfile.MyAppID = "SAAJG" + o.UserID;
                    }


                    db.UserProfiles.Add(oUserProfile);
                    db.SaveChanges();

                    //  var profile = db.UserProfiles.ToList().Where(ite => ite.UserID == oUserProfile.UserID).FirstOrDefault();
                    Session["MyAppId"]   = oUserProfile.MyAppID;
                    Session["UserID"]    = oUserProfile.UserID;
                    Session["Email"]     = o.Email;
                    Session["Phone"]     = o.Mobile;
                    Session["FirstName"] = o.FirstName;
                    Session["MyAppId"]   = oUserProfile.MyAppID;
                    //  SendMail(o.Email);

                    return(RedirectToAction("LandingPage"));
                }
                catch (Exception)
                {
                    return(RedirectToAction("Login"));
                }
            }
            else
            {
                ViewBag.Genders = db.Genders.ToList();
                //ViewBag.Country = db.Countries.ToList();
                //ViewBag.States = db.States.OrderBy(x => x.StateName).ToList();
                //ViewBag.Cities = db.Cities.Where(x => x.StateID == 0).OrderBy(x => x.CityName).ToList();
                return(View(obj));
            }
        }
Esempio n. 3
0
        public ActionResult Register(UserRegVM obj)
        {
            bool em = db.UserRegistrations.Any(x => x.Email == obj.Email);

            if (em == true)
            {
                ModelState.AddModelError("Email", "Email Already Used");
            }
            if (obj.Caste == "")
            {
                ModelState.AddModelError("Caste", "Please select caste");
            }
            if (!obj.TermsAndConditions)
            {
                ModelState.AddModelError("TermsAndConditions", "Please Select Terms & Conditions Box");
            }

            if (ModelState.IsValid)
            {
                try
                {
                    OtherCasteUserRegistration o = new OtherCasteUserRegistration();
                    o.Email        = obj.Email;
                    o.Mobile       = obj.Mobile;
                    o.FirstName    = obj.FirstName;
                    o.MiddleName   = obj.MiddleName;
                    o.LastName     = obj.LastName;
                    o.IsActive     = false;
                    o.Gender       = obj.Gender;
                    o.CasteName    = obj.Caste;
                    o.SubCasteName = obj.SubCaste;
                    o.DOB          = Convert.ToDateTime(obj.BirthDateDisplay);

                    o.CreatedOn = DateTime.Now;
                    db.OtherCasteUserRegistrations.Add(o);
                    db.SaveChanges();



                    return(View("LandingPage"));
                }
                catch (Exception)
                {
                    return(RedirectToAction("Login"));
                }
            }
            else
            {
                var selectlist = new SelectList(
                    new List <SelectListItem>
                {
                    new SelectListItem {
                        Selected = true, Text = "Leva Patil", Value = "Leva Patil"
                    },
                    new SelectListItem {
                        Selected = true, Text = "GujarPatil", Value = "GujarPatil"
                    },
                    new SelectListItem {
                        Selected = true, Text = "Mali", Value = "Mali"
                    },
                    new SelectListItem {
                        Selected = true, Text = "Marwadi", Value = "Marwadi"
                    },
                    new SelectListItem {
                        Selected = true, Text = "Gujarathi", Value = "Gujarathi"
                    },
                    new SelectListItem {
                        Selected = true, Text = "Bramhan", Value = "Bramhan"
                    },
                    new SelectListItem {
                        Selected = true, Text = "Wani", Value = "Wani"
                    },

                    new SelectListItem {
                        Selected = true, Text = "Shimpi", Value = "Shimpi"
                    },
                    new SelectListItem {
                        Selected = true, Text = "Sonar", Value = "Sonar"
                    },
                    new SelectListItem {
                        Selected = true, Text = "Dhobi", Value = "Dhobi"
                    },
                    new SelectListItem {
                        Selected = true, Text = "Badgujar", Value = "Badgujar"
                    },
                    new SelectListItem {
                        Selected = true, Text = "Nhavi", Value = "Nhavi"
                    },
                    new SelectListItem {
                        Selected = true, Text = "Kasar", Value = "Kasar"
                    },
                    new SelectListItem {
                        Selected = true, Text = "Kumbhar", Value = "Kumbhar"
                    },

                    new SelectListItem {
                        Selected = true, Text = "Teli", Value = "Teli"
                    },
                    new SelectListItem {
                        Selected = true, Text = "Bhavsar", Value = "Bhavsar"
                    },

                    new SelectListItem {
                        Selected = true, Text = "Sutar", Value = "Sutar"
                    },
                    new SelectListItem {
                        Selected = true, Text = "Mali", Value = "Mali"
                    },

                    new SelectListItem {
                        Selected = true, Text = "Bari", Value = "Bari"
                    },
                    new SelectListItem {
                        Selected = true, Text = "Gurav", Value = "Gurav"
                    },

                    new SelectListItem {
                        Selected = true, Text = "Manbhav", Value = "Manbhav"
                    },
                    new SelectListItem {
                        Selected = true, Text = "Lohar", Value = "Lohar"
                    },

                    new SelectListItem {
                        Selected = true, Text = "Thakur", Value = "Thakur"
                    },
                    new SelectListItem {
                        Selected = true, Text = "Gosavi", Value = "Gosavi"
                    },

                    new SelectListItem {
                        Selected = true, Text = "Beldar", Value = "Beldar"
                    },
                    new SelectListItem {
                        Selected = true, Text = "Otaari", Value = "Otaari"
                    },


                    new SelectListItem {
                        Selected = true, Text = "Gawali", Value = "Gawali"
                    },
                    new SelectListItem {
                        Selected = true, Text = "Ramoshi", Value = "Ramoshi"
                    },


                    new SelectListItem {
                        Selected = true, Text = "Banjara", Value = "Banjara"
                    },
                    new SelectListItem {
                        Selected = true, Text = "Dhangar", Value = "Dhangar"
                    },
                    new SelectListItem {
                        Selected = true, Text = "Vanjari", Value = "Vanjari"
                    },
                    new SelectListItem {
                        Selected = true, Text = "Other Caste", Value = "OtherCaste"
                    },
                }, "Value", "Text", 1);


                ViewBag.CasteList = selectlist;
                ViewBag.Genders   = db.Genders.ToList();
                return(View(obj));
            }
        }