Beispiel #1
0
        public bool DeleteUser(decimal UserID)
        {
            //ICollection<CM_USER_ROLE_XREF> UserRoleColl = new Collection<CM_USER_ROLE_XREF>();
            CM_USER_PROFILE   up  = new CM_USER_PROFILE();
            CM_USER_ROLE_XREF urx = new CM_USER_ROLE_XREF();

            try
            {
                //First Delete Rec from UserRoleRef
                CM_USER_ROLE_XREF objDelUserRoleRef = (from Profile in db.CM_USER_ROLE_XREF where Profile.USER_ID == UserID select Profile).FirstOrDefault();

                db.CM_USER_ROLE_XREF.Remove(objDelUserRoleRef);
                db.SaveChanges();

                //First Delete Rec from MakerCheckerRef
                //CM_MAKER_CHECKER_XREF objDelMakerCheckerRef = (from MCX in db.CM_MAKER_CHECKER_XREF where MCX.CHECKER_ID == UserID || MCX.MAKER_ID == UserID select MCX).FirstOrDefault();

                //db.CM_MAKER_CHECKER_XREF.Remove(objDelMakerCheckerRef);
                //db.SaveChanges();

                CM_USER_PROFILE objDeleteUser = (from Profile in db.CM_USER_PROFILE where Profile.PROFILE_ID == UserID select Profile).FirstOrDefault();

                db.CM_USER_PROFILE.Remove(objDeleteUser);
                db.SaveChanges();

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
        private void GetDatabaseUserRolesPermissions()
        {
            using (AppDbContext _data = new AppDbContext())
            {
                CM_USER_PROFILE _user = _data.CM_USER_PROFILE.Where(u => u.USER_ID.ToUpper() == this.UserId.ToUpper()).FirstOrDefault();
                if (_user != null)
                {
                    this.ProfileId = (int)_user.PROFILE_ID;

                    CM_USER_ROLES _userRole = _data.CM_USER_ROLES.Where(u => u.ROLE_ID == this.RoleId).FirstOrDefault();

                    List <CM_ROLE_PERM_XREF> _permxref = _data.CM_ROLE_PERM_XREF.Where(p => p.ROLE_ID == _userRole.ROLE_ID).ToList();

                    foreach (CM_ROLE_PERM_XREF _permission in _permxref)
                    {
                        //_userRole.CM_PERMISSIONS.Add(new CM_PERMISSIONS { PERMISSION_ID = (int)_permission.PERMISSION_ID, PERMISSIONDESCRIPTION = _permission.PERMISSIONDESCRIPTION });
                        Permissions.Add(new CM_PERMISSIONS {
                            PERMISSION_ID = (int)_permission.PERMISSION_ID, PERMISSIONDESCRIPTION = ""
                        });
                    }
                    this.Roles.Add(_userRole);
                    //foreach (CM_USER_ROLES _role in _user.CM_USER_ROLES)
                    //{
                    //    UserRole _userRole = new UserRole { Role_Id = _role.ROLE_ID, RoleName = _role.ROLE_NAME };

                    //    this.Roles.Add(_userRole);

                    //    //if (!this.IsSysAdmin)
                    //    //    this.IsSysAdmin = (bool)!_role.IS_DEFAULT;
                    //}
                }
            }
        }
Beispiel #3
0
        //private AppDbContext db;// = new AppDbContext();
        #endregion
        /// <summary>
        /// Inserts a new row in the CM_USER_PROFILE table.
        /// </summary>
        /// <param name="mdmque">A CM_USER_PROFILE object.</param>
        /// <returns>An updated CM_USER_PROFILE object.</returns>
        public CM_USER_PROFILE Insert(CM_USER_PROFILE userprofile)
        {
            using (var db = new AppDbContext())
            {
                db.Set <CM_USER_PROFILE>().Add(userprofile);
                db.SaveChanges();

                return(userprofile);
            }
        }
Beispiel #4
0
        public bool CreateUser(string username, string password, string RoleId, string FName, string LName, string Email)
        {
            string salt = null;

            ICollection <CM_USER_ROLE_XREF> UserRoleColl = new Collection <CM_USER_ROLE_XREF>();
            CM_USER_PROFILE up           = new CM_USER_PROFILE();
            string          passwordHash = pwdManager.GeneratePasswordHash(password, out salt);
            int             profileId    = 0;

            using (var cdma = new AppDbContext())
            {
                var usr = new CM_USER_PROFILE
                {
                    COD_PASSWORD            = passwordHash,
                    PASSWORDSALT            = salt,
                    USER_ID                 = username,
                    ISLOCKED                = false, //isLoggedin
                    CREATED_DATE            = DateTime.Now,
                    ROLE_ID                 = Convert.ToInt32(RoleId),
                    FIRSTNAME               = FName,
                    LASTNAME                = LName,
                    DISPLAY_NAME            = (FName.Substring(0, 1) + LName).ToLower(),
                    EMAIL_ADDRESS           = Email,
                    ISAPPROVED              = true,
                    LASTLOGINDATE           = DateTime.Now,
                    LASTLOCKOUTDATE         = DateTime.Now,
                    LASTPASSWORDCHANGEDDATE = DateTime.Now
                };
                cdma.CM_USER_PROFILE.Add(usr);
                cdma.SaveChanges();
                profileId = usr.PROFILE_ID;
            }

            CM_USER_ROLE_XREF urx = new CM_USER_ROLE_XREF();

            urx.USER_ID = profileId;
            urx.ROLE_ID = Convert.ToInt32(RoleId);

            UserRoleColl.Add(urx);

            up.CM_USER_ROLE_XREF = UserRoleColl;

            db.CM_USER_ROLE_XREF.Add(urx);
            db.SaveChanges();

            if (up.PROFILE_ID == null)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Beispiel #5
0
        /// <summary>
        /// Updates the queitem
        /// </summary>
        /// <param name="queitem">queitem</param>
        public virtual void UpdateQueItem(CM_USER_PROFILE queitem)
        {
            if (queitem == null)
            {
                throw new ArgumentNullException("queitem");
            }

            _useradminDAC.Update(queitem);

            //event notification
            //_eventPublisher.EntityUpdated(vendor);
        }
Beispiel #6
0
        /// <summary>
        /// Delete an item
        /// </summary>
        /// <param name="queitem">QueItem</param>
        public virtual void DeleteQueItem(CM_USER_PROFILE queitem)
        {
            if (queitem == null)
            {
                throw new ArgumentNullException("user");
            }

            UpdateQueItem(queitem);

            //event notification
            //_eventPublisher.EntityDeleted(vendor);
        }
Beispiel #7
0
        /// <summary>
        /// Updates an existing row in the userprofile table.
        /// </summary>
        /// <param name="userprofile">A userprofile entity object.</param>
        public void Update(CM_USER_PROFILE userprofile)
        {
            using (var db = new AppDbContext())
            {
                var entry = db.Entry <CM_USER_PROFILE>(userprofile);

                // Re-attach the entity.
                entry.State = EntityState.Modified;

                db.SaveChanges();
            }
        }
Beispiel #8
0
        public decimal getProfileID(string p)
        {
            decimal         status = 0;
            CM_USER_PROFILE up     = new CM_USER_PROFILE();

            var profID = from n in db.CM_USER_PROFILE
                         where n.USER_ID == p.ToString()
                         select new { n.PROFILE_ID };

            status = profID.FirstOrDefault().PROFILE_ID;

            return(status);
        }
Beispiel #9
0
        public override int GetNumberOfUsersOnline()
        {
            int             status = 0;
            CM_USER_PROFILE up     = new CM_USER_PROFILE();

            var count = from n in db.CM_USER_PROFILE
                        //where n.ISLOCKED == 1
                        select new { n.PROFILE_ID };


            status = count.Count();

            return(status);
        }
 public CustomMembershipUser(CM_USER_PROFILE user)
     : base("CustomMembershipProvider", user.USER_ID, user.PROFILE_ID, user.EMAIL_ADDRESS, string.Empty, string.Empty, true, false,
            user.CREATED_DATE, (DateTime)user.LASTLOGINDATE, DateTime.Now, DateTime.Now, DateTime.Now)
 {
     FirstName    = user.FIRSTNAME;
     LastName     = user.LASTNAME;
     UserRoleId   = (int)user.ROLE_ID;
     UserRoleName = user.CM_USER_ROLES.ROLE_NAME;
     DisplayName  = user.DISPLAY_NAME;
     ProfileId    = (int)user.PROFILE_ID;
     BranchId     = user.BRANCH_ID;
     BranchName   = user.CM_BRANCH.BRANCH_NAME;
     RegionId     = user.CM_BRANCH.REGION_ID;
     RegionName   = user.CM_BRANCH.REGION_NAME;
     ZoneId       = user.CM_BRANCH.ZONECODE;
     ZoneName     = user.CM_BRANCH.ZONENAME;
 }
Beispiel #11
0
        public bool checkUserName(string Username)
        {
            bool            status = false;
            CM_USER_PROFILE upl    = new CM_USER_PROFILE();

            var count = from n in db.CM_USER_PROFILE
                        where (n.USER_ID == Username)
                        select new { n.PROFILE_ID };

            if (count.Count() > 0)
            {
                status = true;
            }
            else
            {
                status = false;
            }
            return(status);
        }
Beispiel #12
0
        public bool getUserr(string Username, string Email)
        {
            bool            status = false;
            CM_USER_PROFILE upl    = new CM_USER_PROFILE();

            var count = from n in db.CM_USER_PROFILE
                        where (n.USER_ID == Username && n.EMAIL_ADDRESS == Email)
                        select new { n.PROFILE_ID };

            if (count.Count() > 0)
            {
                status = true;
            }
            else
            {
                status = false;
            }
            return(status);
        }