예제 #1
0
 // Start is called before the first frame update
 void Start()
 {
     showUserInstance = this;
     backBtn.onClick.AddListener(() =>
     {
         Main.instance.SetHomeScreenActive();
     });
 }
        public void Auth()
        {
            var dbUser         = UsersDAO.GetUserByLogin(Login);
            var hashedPassword = PasswordUtilities.ComputeHash(Password, new MD5CryptoServiceProvider());

            if (dbUser != null)         // USER FOUND
            {
                if (dbUser.IsSuperUser) // SUPERUSER
                {
                    var superUser = (SuperUser)dbUser;
                    if (superUser.HashedPassword == hashedPassword) // SUPERUSER WANTS TO ACCESS ADMIN PANEL
                    {
                        var adminPanel   = new AdminPanel();
                        var activeWindow = Application.Current.Windows.OfType <Window>().SingleOrDefault(x => x.IsActive);
                        adminPanel.Show();
                        activeWindow.Close();
                    }
                } // USER
                else
                {
                    if (dbUser.HashedPassword == hashedPassword)
                    {
                        var usersManagementWindow = new ShowUserDetails(dbUser);
                        var activeWindow          = Application.Current.Windows.OfType <Window>().SingleOrDefault(x => x.IsActive);
                        usersManagementWindow.Show();
                        activeWindow.Close();
                        return;
                    }
                    var listSuperPasswords = UsersDAO.GetSuperPasswords();
                    foreach (var pass in listSuperPasswords)
                    {
                        if (pass == hashedPassword) // SUPERUSER WANTS TO ACCESS USER PANEL
                        {
                            var showUserDetailsWindow = new ShowUserDetails(dbUser);
                            var activeWindow          =
                                Application.Current.Windows.OfType <Window>().SingleOrDefault(x => x.IsActive);
                            showUserDetailsWindow.Show();
                            activeWindow.Close();
                            return;
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("Wrong login or password!");
            }
        }
예제 #3
0
        public ActionResult UpdateUserDetails(ShowUserDetails userDetail, HttpPostedFileBase postedFile)
        {
            try
            {
                int userId         = Convert.ToInt32(Session[SessionObjects.CNUserId]);
                var getUserDetails = userBs.checkUserIdExist(userId);
                if (getUserDetails != 0)
                {
                    //Update
                    if (ModelState.IsValid)
                    {
                        bool updateUserDetail = userBs.UpdateUserDetail(userId, userDetail.updateUserDetail, userDetail.updateUser, postedFile);
                        if (updateUserDetail == true)
                        {
                            var getUserProfileImage = userBs.GetUserProfileImage(userId);
                            if (getUserProfileImage != null)
                            {
                                Session["CNUserImage"]              = null;
                                Session[SessionObjects.CNUserName]  = null;
                                Session[SessionObjects.CNUserEmail] = null;
                                CommanDetails profileImage = new CommanDetails();
                                profileImage.Image                  = getUserProfileImage.Image;
                                profileImage.ImageName              = getUserProfileImage.ImageName;
                                profileImage.ImageType              = getUserProfileImage.ImageType;
                                Session[SessionObjects.CNUserName]  = getUserProfileImage.Name;
                                Session[SessionObjects.CNUserEmail] = getUserProfileImage.Email;
                                Session["CNUserImage"]              = profileImage;
                            }
                            TempData["Msg"] = "User detail update successfully";
                        }
                    }
                }
                else
                {
                    //Insert
                    if (ModelState.IsValid)
                    {
                        bool insertUserDetail = userBs.InsertUserDetail(userId, userDetail.updateUserDetail, userDetail.updateUser, postedFile);
                        if (insertUserDetail == true)
                        {
                            var getUserProfileImage = userBs.GetUserProfileImage(userId);
                            if (getUserProfileImage != null)
                            {
                                Session["CNUserImage"] = null;
                                CommanDetails profileImage = new CommanDetails();
                                profileImage.Image     = getUserProfileImage.Image;
                                profileImage.ImageName = getUserProfileImage.ImageName;
                                profileImage.ImageType = getUserProfileImage.ImageType;
                                Session["CNUserImage"] = profileImage;
                            }
                            TempData["Msg"] = "User detail update successfully";
                        }
                    }
                }
                return(RedirectToAction("UserProfile", "Profile", new { area = "UsersSection" }));
            }
            catch (Exception ex)
            {
                TempData["Fail"] = "Something went wrong . Please contact to administrator." + ex;
                return(RedirectToAction("UserProfile", "Profile", new { area = "UsersSection" }));

                throw;
            }
        }
예제 #4
0
 public ShowUserDetails GetUserDetailById(int userId)
 {
     try
     {
         ShowUserDetails showUserDetails = new ShowUserDetails();
         var             getUser         = (from o in mVCDemoEntities.Users
                                            where o.UserId == userId
                                            select new
         {
             o.Email,
             o.Name
         }).FirstOrDefault();
         if (getUser != null)
         {
             UpdateUser upUser = new UpdateUser();
             upUser.Name  = getUser.Name;
             upUser.Email = getUser.Email;
             //Add User Name and email
             showUserDetails.updateUser = upUser;
         }
         else
         {
             showUserDetails.updateUser = null;
         }
         var getUserDetail = (from o in mVCDemoEntities.UserDetails
                              where o.UserId == userId
                              select new
         {
             o.Address,
             o.LandMark,
             o.GenderId,
             o.CountryId,
             o.StateId,
             o.CityId,
             o.Phone,
             o.PostalCode,
             o.DOB
         }).FirstOrDefault();
         if (getUserDetail != null)
         {
             UpdateUserDetail upUserDetail = new UpdateUserDetail();
             upUserDetail.Address    = getUserDetail.Address;
             upUserDetail.LandMark   = getUserDetail.LandMark;
             upUserDetail.GenderId   = getUserDetail.GenderId;
             upUserDetail.CountryId  = getUserDetail.CountryId;
             upUserDetail.StateId    = getUserDetail.StateId;
             upUserDetail.CityId     = getUserDetail.CityId;
             upUserDetail.Phone      = getUserDetail.Phone;
             upUserDetail.PostalCode = getUserDetail.PostalCode;
             string dob  = Convert.ToString(getUserDetail.DOB);
             string dd   = dob.Substring(0, 2);
             string mm   = dob.Substring(3, 2);
             string yyyy = dob.Substring(6, 4);
             upUserDetail.DOB    = getUserDetail.DOB;//Convert.ToDateTime(dd + "-" + mm + "-" + yyyy);
             upUserDetail.IsEdit = true;
             showUserDetails.updateUserDetail = upUserDetail;
         }
         else
         {
             showUserDetails = null;
         }
         return(showUserDetails);
     }
     catch (Exception)
     {
         throw;
     }
 }