Пример #1
0
        public ActionResult EditUserProfile()
        {
            long UserId;

            UserId = Convert.ToInt64(Session["UserID"].ToString());

            UserProfileModel us = new UserProfileModel();
            var UserRoles       = new UserRolesLocalView();

            bool IsGroupAdmin = (Session["UserRoles"].ToString()).Split(',').Select(int.Parse).ToArray().Contains(2);
            //var currentLoginUser = Convert.ToInt64(Session["UserID"].ToString());
            // find the user in userprofile table
            var userExist = db.UserProfiles.Find(UserId);

            if (userExist.IsDelete == false) // record is not deleted.
            {
                // update and save the record.
                us.UserId         = userExist.UserId;
                us.ID             = userExist.Id;
                us.EmployeeID     = userExist.EmployeeID;
                us.FirstName      = userExist.FirstName;
                us.LastName       = userExist.LastName;
                us.EmailAddress   = userExist.EmailAddress;
                us.ContactNo      = userExist.ContactNo;
                us.ManagerName    = userExist.ManagerName;
                us.Designation    = userExist.Designation;
                us.OrganisationID = (int)userExist.OrganisationID;
                //us.OrganisationName = String.IsNullOrWhiteSpace(userExist.Organisation.OrganisationName) ? "" : userExist.Organisation.OrganisationName;
                us.Status         = userExist.Status;
                us.Option1        = userExist.Option1;
                us.Option2        = userExist.Option2;
                us.UserLanguageId = Convert.ToInt32(userExist.LanguageId);
                us.IsGroupAdmin   = IsGroupAdmin;
            }

            //var userroles = UserManager.GetRoles(userExist.Id);
            //var selectedRolesLocal = db.AspNetRoles.Where(rol => userroles.Contains(rol.Name)).Select(rol => new UserRolesLocal { RoleId = rol.Id, RoleName = rol.Name, IsSelected = true }).OrderByDescending(rol => rol.RoleName).ToList();
            //if (IsGroupAdmin)
            //    UserRoles.AvailableRoles = db.AspNetRoles.Where(x => x.Name != "Administrator").Select(rol => new UserRolesLocal { RoleId = rol.Id, RoleName = rol.Name, IsSelected = false }).ToList();
            //else
            //    UserRoles.AvailableRoles = db.AspNetRoles.Select(rol => new UserRolesLocal { RoleId = rol.Id, RoleName = rol.Name, IsSelected = false }).ToList();
            //UserRoles.SelectedRoles = selectedRolesLocal;
            //us.ActionType = 0;
            //us.UserRolesList = UserRoles;

            //if (IsGroupAdmin)
            //{
            //    ViewBag.OrgList = new SelectList(db.Organisations.Where(org => org.Status == true && org.OrganisationID == userExist.OrganisationID).OrderBy(org => org.OrganisationName).Select(org => org), "OrganisationID", "OrganisationName");
            //}
            //else
            //{
            //    ViewBag.OrgList = new SelectList(db.Organisations.Where(org => org.Status == true).OrderBy(org => org.OrganisationName).Select(org => org), "OrganisationID", "OrganisationName");
            //}
            //ViewBag.OrgList = new SelectList(db.Organisations.Where(org => org.Status == true).OrderBy(org => org.OrganisationName).Select(org => org), "OrganisationID", "OrganisationName", db.Organisations.Find(us.OrganisationID));
            return(View(us));
        }
Пример #2
0
        public ActionResult EditUserProfile()
        {
            long UserId;

            UserId = Convert.ToInt64(Session["UserID"].ToString());

            UserProfileModel us = new UserProfileModel();
            var UserRoles       = new UserRolesLocalView();

            bool IsGroupAdmin = (Session["UserRoles"].ToString()).Split(',').Select(int.Parse).ToArray().Contains(2);
            //var currentLoginUser = Convert.ToInt64(Session["UserID"].ToString());
            // find the user in userprofile table
            var userExist = db.UserProfiles.Find(UserId);

            if (userExist.IsDelete == false) // record is not deleted.
            {
                // update and save the record.
                us.UserId         = userExist.UserId;
                us.ID             = userExist.Id;
                us.EmployeeID     = userExist.EmployeeID;
                us.FirstName      = userExist.FirstName;
                us.LastName       = userExist.LastName;
                us.EmailAddress   = userExist.EmailAddress;
                us.ContactNo      = userExist.ContactNo;
                us.ManagerName    = userExist.ManagerName;
                us.Designation    = userExist.Designation;
                us.OrganisationID = (int)userExist.OrganisationID;
                //us.OrganisationName = String.IsNullOrWhiteSpace(userExist.Organisation.OrganisationName) ? "" : userExist.Organisation.OrganisationName;
                us.Status         = userExist.Status;
                us.Option1        = userExist.Option1;
                us.Option2        = userExist.Option2;
                us.UserLanguageId = Convert.ToInt32(userExist.LanguageId);
                us.IsGroupAdmin   = IsGroupAdmin;
            }

            return(View(us));
        }