예제 #1
0
        public ActionResult ForgotPassword(string UserName)
        {
            //check user existance
            if (UserName == null)
            {
                TempData["Message"] = "User Not exist.";
            }
            else
            {
                //create url with above token
                var resetLink = "<a href='" + Url.Action("ResetPassword", "CommonView", new { un = UserName }, "http") + "'>Reset Password</a>";
                //get user emailid
                HealthCareEntities db = new HealthCareEntities();
                var emailid           = (from i in db.UserProfiles
                                         where i.Email == UserName
                                         select i.Email).FirstOrDefault();
                //send mail
                string subject = "Password Reset Token";
                string body    = "<b>Please find the Password Reset Token</b><br/>" + resetLink; //edit it
                try
                {
                    Mail.SendEMail(emailid, subject, body);
                    TempData["Message"] = "Mail Sent.";
                    return(RedirectToAction("Login", "CommonView"));
                }
                catch (Exception ex)
                {
                    TempData["Message"] = "Error occured while sending email." + ex.Message;
                }
                //only for testing
                TempData["Message"] = resetLink;
            }

            return(View());
        }
예제 #2
0
        public ActionResult ResetPassword(string un, string password)
        {
            HealthCareEntities db = new HealthCareEntities();
            //TODO: Check the un and rt matching and then perform following
            //get userid of received username
            var userid = (from i in db.UserProfiles
                          where i.Email == un
                          select i.Id).FirstOrDefault();
            //check userid and token matches
            var userEmail = (from i in db.UserProfiles
                             where i.Email == un
                             select i.Email).FirstOrDefault();

            if (userEmail != null)
            {
                var passwordUpdated = _userservice.ResetPassword(userid, un, password);
                if (passwordUpdated == true)
                {
                    //get user emailid to send password
                    var emailid = (from i in db.UserProfiles
                                   where i.Email == un
                                   select i.Email).FirstOrDefault();
                    //send email
                    string subject = "New Password";
                    string body    = "<b>Please find the New Password</b><br/>" + password; //edit it
                    try
                    {
                        Mail.SendEMail(emailid, subject, body);
                        TempData["Message"] = "Mail Sent.";
                        return(RedirectToAction("Login", "CommonView"));
                    }
                    catch (Exception ex)
                    {
                        TempData["Message"] = "Error occured while sending email." + ex.Message;
                    }

                    //display message
                    TempData["Message"] = "Success! Check email we sent. Your New Password Is " + password;
                }
                else
                {
                    TempData["Message"] = "Hey, avoid random request on this page.";
                }
            }
            else
            {
                TempData["Message"] = "Username and token not maching.";
            }

            return(View());
        }
예제 #3
0
 /// <summary>
 /// Public Constructor,initializes privately declared local variables.
 /// </summary>
 /// <param name="context"></param>
 public GenericRepository(HealthCareEntities context)
 {
     this.Context = context;
     this.DbSet   = context.Set <TEntity>();
 }
 public ContactController()
 {
     // create instance of an object
     dbContext = new HealthCareEntities();
 }
예제 #5
0
        //private GenericRepository<Adverstisement> _adverstisementRepository;
        //private GenericRepository<CMSPage> _cmspageRepository;
        //private GenericRepository<Slider> _sliderRepository;
        //private GenericRepository<Event> _eventRepository;
        #endregion

        public UnitOfWork()
        {
            _context = new HealthCareEntities();
        }