Пример #1
0
 public ActionResult changepassword(UserProfile userprofile)
 {
     try
     {
         MsInUsEntities connection = new MsInUsEntities();
         int            id         = Convert.ToInt32(Session["UserId"]);
         UserProfile    usobj      = connection.UserProfiles.SingleOrDefault(m => m.Id == id);
         usobj.Password         = MyEncryption.EncodePasswordToBase64(userprofile.Password);
         usobj.ConfirmPassword  = MyEncryption.EncodePasswordToBase64(userprofile.ConfirmPassword);
         usobj.Email_IdRegister = usobj.Email_Id;
         connection.SaveChanges();
         TempData["ConfirmationMessage"] = "Password Changed Successfully!";
     }
     catch (System.Data.Entity.Validation.DbEntityValidationException e)
     {
         StreamWriter sw = new StreamWriter(@"D:\MasterStudy\MsInUsa\MsInUsa\Log\logs.txt", true);
         foreach (var c in e.EntityValidationErrors)
         {
             foreach (var ex in c.ValidationErrors)
             {
                 sw.WriteLine(ex.ErrorMessage);
             }
         }
         sw.Close();
         return(RedirectToAction("NotFound", "Error"));
     }
     return(RedirectToAction("changepassword", "Account"));
 }
Пример #2
0
 public ActionResult Register(UserProfile userprofile)
 {
     if (userprofile != null)
     {
         using (MsInUsEntities msInUsConnection = new MsInUsEntities())
         {
             int rowcount = msInUsConnection.UserProfiles.Count();
             userprofile.Password        = MyEncryption.EncodePasswordToBase64(userprofile.Password);
             userprofile.ConfirmPassword = MyEncryption.EncodePasswordToBase64(userprofile.ConfirmPassword);
             userprofile.Email_Id        = userprofile.Email_IdRegister;
             msInUsConnection.UserProfiles.Add(userprofile);
             msInUsConnection.SaveChanges();
             TempData["ConfirmationMessage"] = "Registered Successfully";
             //Session.Add("Registration Message", "Registered Successfully");
             if (rowcount < msInUsConnection.UserProfiles.Count())
             {
                 return(RedirectToAction("LogIn", "Account"));
             }
         }
     }
     return(RedirectToAction("NotFound", "Error"));
 }