示例#1
0
        public ActionResult Signups(UserModel Model)
        {
            if (ModelState.IsValid)
            {
                Enterintotable en = new Enterintotable();

                Model.ActivationKey = Guid.NewGuid().ToString();

                var isexist = dba.Users.Where(c => c.Email.Trim().ToLower() == Model.Email.Trim().ToLower()).FirstOrDefault();
                if (isexist == null)
                {
                    en.InsertUser(Model);
                }
                else
                {
                    @ViewBag.data = "Email already exists.";
                    return(View("Signup"));
                }

                CommonCls.SendMailToUser(Model.Email, "", "Registration", Model.ActivationKey);
                ModelState.Clear();
                @ViewBag.Message = "Your account has been created Successfully. An Account Confirmation has been sent to your Email.";
                return(View("Signup"));
            }
            else
            {
                return(View("Signup"));
            }
        }
        public ActionResult ApproveEvents(int?Id)
        {
            if (Id != 0)
            {
                var location = _LocationService.GetLocations().Where(l => l.LocationId == Id).FirstOrDefault();

                if (location != null)
                {
                    location.IsApproved = true;
                    location.Status     = EnumValue.GetEnumDescription(EnumValue.LocationStatus.Approved);
                    _LocationService.UpdateLocation(location);
                    CommonCls.SendMailToUser("", "", "");
                }
                TempData["ShowMessage"] = "success";
                TempData["MessageBody"] = " Location approved  successfully.";
                return(RedirectToAction("Index"));
            }



            else
            {
                TempData["ShowMessage"] = "error";
                TempData["MessageBody"] = " Location not found. ";
                return(RedirectToAction("Details", new { Id = Id }));
            }
        }
        public ActionResult ForgotPassword([Bind(Include = "UserName")] ForgotPasswordModel model)
        {
            try
            {
                if (string.IsNullOrEmpty(model.UserName))
                {
                    ModelState.AddModelError("Name", "Please enter email.");
                }
                if (ModelState.IsValid)
                {
                    string UserName = "";
                    var    user     = _UserService.GetUserByEmailId(model.UserName);
                    if (user != null)              //By Email Id
                    {
                        UserName = user.FirstName; //Get User Name

                        //Send Email to User
                        string Password = SecurityFunction.DecryptString(user.Password);
                        CommonCls.SendMailToUser(UserName, model.UserName, Password);
                        TempData["MessageBody"] = "Your password has been sent to this email address.";
                        ViewBag.Error           = TempData["MessageBody"];
                    }
                    else
                    {
                        TempData["MessageBody"] = "This email address does not exist in our records.";
                        ViewBag.Error           = TempData["MessageBody"];
                    }
                }
            }
            catch (Exception ex)
            {
                string ErrorMsg = ex.Message.ToString();//
                ErrorLogging.LogError(ex);
            }
            var errors           = ModelState.Where(x => x.Value.Errors.Count > 0).Select(x => new { x.Key, x.Value.Errors }).ToArray();
            var modelStateErrors = this.ModelState.Keys.SelectMany(key => this.ModelState[key].Errors);

            return(View(model));
        }
示例#4
0
        public ActionResult ForgotPassword(string Email)
        {
            try
            {
                if (string.IsNullOrEmpty(Email))
                {
                    ModelState.AddModelError("Email", "Please enter email.");
                }
                if (ModelState.IsValid)
                {
                    var user = dba.Users.Where(c => c.Email.ToLower() == Email.ToLower()).FirstOrDefault();
                    if (user != null)
                    {
                        //Send Email to User
                        CommonCls.SendMailToUser(Email, user.Password, "Forgot Password");
                        @ViewBag.data = "Your password has been sent to this email address.";
                        ModelState.Clear();
                        return(View("ForgotPassword"));
                    }
                    else
                    {
                        @ViewBag.data = "This email address does not exist in our records.";
                        return(View("ForgotPassword"));
                    }
                }
            }
            catch (Exception ex)
            {
                string ErrorMsg = ex.Message.ToString();
                //ErrorLogging.LogError(ex);
            }
            var errors           = ModelState.Where(x => x.Value.Errors.Count > 0).Select(x => new { x.Key, x.Value.Errors }).ToArray();
            var modelStateErrors = this.ModelState.Keys.SelectMany(key => this.ModelState[key].Errors);

            return(View());
        }