Beispiel #1
0
 private void setAutheniticated(string username)
 {
     try
     {
         DT_WebGISEntities MyContext  = new DT_WebGISEntities();
         CSF_Users_DAO     objUserDao = new CSF_Users_DAO();
         var user = objUserDao.GetByUserName(username);
         if (user == null)
         {
             CSF_Users obj = new CSF_Users();
             obj.UserName     = username;
             obj.FullName     = username;
             obj.Status       = 1;
             obj.RegisterDate = DateTime.Now;
             obj.Email        = username + "@monre.gov.vn";
             obj.Password     = Encryptor.MD5Hash("e10adc3949ba59abbe56e057f20f883e");
             MyContext.CSF_Users.Add(obj);
             MyContext.SaveChanges();
             if (obj.ID > 0)
             {
                 int          IDRegistedGroup = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["IDRegistedGroup"]);
                 CSF_UserRole objUR           = new CSF_UserRole();
                 objUR.RoleID = IDRegistedGroup;
                 objUR.UserID = obj.ID;
                 MyContext.CSF_UserRole.Add(objUR);
                 MyContext.SaveChanges();
             }
         }
         FormsAuthentication.SetAuthCookie(username, false);
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
     }
 }
Beispiel #2
0
 public ActionResult UpdateInformation(string id)
 {
     try
     {
         CSF_Users_DAO objUsersDAO = new CSF_Users_DAO();
         var           user        = objUsersDAO.GetByUserName(id);
         if (user == null)
         {
             return(RedirectToAction("Index", "QT_Home"));
         }
         if (id.ToLower().Trim() != HttpContext.User.Identity.Name.ToLower().Trim())
         {
             return(RedirectToAction("Index", "QT_Home"));
         }
         ViewBag.ID = user.ID;
         return(View(user));
     }
     catch (Exception ex)
     {
         SetAlert("Lỗi" + ex.Message.ToString(), AlertType.Error);
         Logs.WriteLog(ex);
         return(View());
     }
 }