private List <SecUserInfo> LoadSecUserInfo()
        {
            List <SecUserInfo> SUInfList = new List <SecUserInfo>();

            var UList = _secUserInfoService.All().ToList();

            if (UList.Count > 0)
            {
                foreach (var uObj in UList)
                {
                    SecUserInfo sui = new SecUserInfo();
                    sui.UserID     = uObj.UserID;
                    sui.UserName   = uObj.UserName;
                    sui.Password   = uObj.Password;
                    sui.Email      = uObj.Email;
                    sui.CreateDate = uObj.CreateDate;

                    SUInfList.Add(sui);
                }

                if (SUInfList != null)
                {
                    SUInfList = SUInfList.OrderBy(x => x.UserName).ToList();
                }

                return(SUInfList);
            }
            else
            {
                return(null);
            }
        }
        public ActionResult GetSecUserInfoByID(int UserID)
        {
            try
            {
                SecUserInfo sug = new SecUserInfo();

                var SecUsr = _secUserInfoService.All().ToList().FirstOrDefault(x => x.UserID == UserID);

                //SecUserInfo sug = new SecUserInfo();
                //var SecGrp = _secUserInfoService.All().ToList().FirstOrDefault(x => x.UserID == UserID);

                if (SecUsr != null)
                {
                    sug.UserID       = SecUsr.UserID;
                    sug.UserName     = SecUsr.UserName;
                    sug.Password     = SecUsr.Password;
                    sug.ConfPassword = SecUsr.Password;
                    sug.Email        = SecUsr.Email;
                    sug.CreateDate   = SecUsr.CreateDate;
                }
                //    foreach (var SFR in SecGrpList)
                //    {
                //        SecUserInfo Sfrt = new SecUserInfo();
                //        Sfrt.FormRightID = SFR.FormRightID;
                //        Sfrt.UserID = SFR.UserID;
                //        Sfrt.FormProcessID = SFR.FormProcessID;

                //        sug.SecUserInfos.Add(Sfrt);
                //    }

                //}

                var serializerSettings = new JsonSerializerSettings {
                    PreserveReferencesHandling = PreserveReferencesHandling.Objects
                };

                string json = JsonConvert.SerializeObject(sug, Formatting.Indented, serializerSettings);

                if (sug != null && sug.UserID > 0)
                {
                    return(Json(json, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new EmptyResult(), JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception)
            {
                return(Json("0", JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult SaveSecUserInfo(SecUserInfo SecUsrInfo)
        {
            RBACUser rUser = new RBACUser(Session["UserName"].ToString());

            if (!rUser.HasPermission("SecUserInfo_Insert"))
            {
                return(Json("X", JsonRequestBehavior.AllowGet));
            }

            string eCode = "";

            using (var transaction = new TransactionScope())
            {
                try
                {
                    var UserInfo = _secUserInfoService.All().ToList().FirstOrDefault(x => x.UserName == SecUsrInfo.UserName);

                    if (UserInfo == null)
                    {
                        SecUserInfo SecUinf = new SecUserInfo();
                        SecUinf.UserName   = SecUsrInfo.UserName;
                        SecUinf.Password   = SHA1.Encode(SecUsrInfo.Password);
                        SecUinf.Email      = SecUsrInfo.Email;
                        SecUinf.CreateDate = System.DateTime.Now;
                        _secUserInfoService.Add(SecUinf);
                        _secUserInfoService.Save();
                        //For user branch table by Farhad
                        var        userId = _secUserInfoService.All().ToList().Where(x => x.UserName == SecUsrInfo.UserName).Select(s => s.UserID).FirstOrDefault();
                        UserBranch UB     = new UserBranch();
                        UB.Userid     = userId.ToString();
                        UB.BranchCode = "01";
                        _userBranchService.Add(UB);
                        _userBranchService.Save();
                        eCode = "1";
                    }
                    else
                    {
                        eCode = "2";
                    }

                    transaction.Complete();

                    return(Json(eCode, JsonRequestBehavior.AllowGet));
                }
                catch (Exception)
                {
                    transaction.Dispose();
                    return(Json("0", JsonRequestBehavior.AllowGet));
                }
            }
        }
        public ActionResult UpdateSecUserInfo(SecUserInfo SecUsrInfo)
        {
            RBACUser rUser = new RBACUser(Session["UserName"].ToString());

            if (!rUser.HasPermission("SecUserInfo_Update"))
            {
                return(Json("U", JsonRequestBehavior.AllowGet));
            }

            string eCode = "";

            using (var transaction = new TransactionScope())
            {
                try
                {
                    SecUserInfo secuinf = new SecUserInfo();

                    //secfr = _secUserInfoService.All().ToList().FirstOrDefault(x => x.UserID == SecFrmRht.UserID);

                    secuinf = _secUserInfoService.All().ToList().FirstOrDefault(x => x.UserID == SecUsrInfo.UserID);

                    if (secuinf != null)
                    {
                        secuinf.UserName   = SecUsrInfo.UserName;
                        secuinf.Password   = SHA1.Encode(SecUsrInfo.Password);
                        secuinf.Email      = SecUsrInfo.Email;
                        secuinf.CreateDate = System.DateTime.Now;//SecUsrInfo.CreateDate;

                        _secUserInfoService.Update(secuinf);
                        _secUserInfoService.Save();


                        eCode = "1";
                    }
                    else
                    {
                        eCode = "2";
                    }

                    transaction.Complete();

                    return(Json(eCode, JsonRequestBehavior.AllowGet));
                }
                catch (Exception)
                {
                    transaction.Dispose();
                    return(Json("0", JsonRequestBehavior.AllowGet));
                }
            }
        }
        private void GetDatabaseUserRolesPermissions()
        {
            using (ERPConfigurationContext _data = new ERPConfigurationContext())
            {
                SecUserInfo _user = _data.SecUserInfo.Where(u => u.UserName == this.UserName).FirstOrDefault();
                if (_user != null)
                {
                    this.UserID = _user.UserID;
                    foreach (SecUserInGroup _group in _user.SecUserInGroups)
                    {
                        SecUserGroup _uGroup = _data.SecUserGroup.Where(u => u.GroupID == _group.GroupID).FirstOrDefault();

                        UserRole _userRole = new UserRole {
                            Role_Id = _group.GroupID, RoleName = _uGroup.GroupName
                        };

                        List <SecFormRight> _fRightList = _data.SecFormRight.Where(u => u.GroupID == _group.GroupID).ToList();

                        foreach (SecFormRight _fRight in _fRightList)
                        {
                            SecFormProcess _fproc  = _data.SecFormProcess.Where(u => u.FormProcessID == _fRight.FormProcessID).FirstOrDefault();
                            SecFormList    _frmLst = _data.SecFormList.Where(u => u.FormID == _fproc.FormID).FirstOrDefault();

                            _userRole.Permissions.Add(new RolePermission {
                                FormName = _frmLst.FormName, PermissionName = _fproc.ProcessName
                            });
                        }
                        this.Roles.Add(_userRole);

                        //if (!this.IsSysAdmin)
                        //    this.IsSysAdmin = _group.IsSysAdmin;
                    }
                }
            }

            //}
        }
Exemplo n.º 6
0
 public void Setvalues(SecUserInfo entity, SecUserInfo existingEntity)
 {
     _service.Setvalues(entity, existingEntity);
 }
Exemplo n.º 7
0
 public void Delete(SecUserInfo obj)
 {
     _service.Delete(obj);
 }
Exemplo n.º 8
0
 public void Update(SecUserInfo obj)
 {
     _service.Update(obj);
 }
Exemplo n.º 9
0
 public void Add(SecUserInfo obj)
 {
     _service.Add(obj);
 }