예제 #1
0
        /// <summary>
        /// This function will fetch all the senior of any particluar employee
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public List <UserRoleBO> GetSeniors(long userId)
        {
            List <UserRoleBO> users = new List <UserRoleBO>();

            foreach (var item in ReportRepository.GetSeniors(userId))
            {
                UserRoleBO objUserRoleBo = new UserRoleBO();
                objUserRoleBo.UserRoleID      = item.UserRoleID;
                objUserRoleBo.RoleID          = item.RoleID;
                objUserRoleBo.UserID          = item.UserID;
                objUserRoleBo.UserName        = item.UserMaster.FirstName;
                objUserRoleBo.IsActive        = item.IsActive;
                objUserRoleBo.ProductTypeID   = item.ProductTypeID;
                objUserRoleBo.ProductGroupID  = item.ProductGroupID;
                objUserRoleBo.GeoID           = item.GeoID;
                objUserRoleBo.GeoLevelValue   = item.GeoLevelValue;
                objUserRoleBo.ReportingUserID = item.ReportingUserID;
                objUserRoleBo.CreatedDate     = item.CreatedDate;
                objUserRoleBo.CreatedBy       = item.CreatedBy;
                objUserRoleBo.ModifiedDate    = item.ModifiedDate;
                objUserRoleBo.ModifiedBy      = item.ModifiedBy;
                objUserRoleBo.IsDeleted       = item.IsDeleted;
                users.Add(objUserRoleBo);
            }
            //ObjectMapper.Map(ReportRepository.GetSeniors(userId), users);
            return(users);
        }
예제 #2
0
 public bool AddRole(Guid roleId, Guid userId)
 {
     try
     {
         var userRoleBO = new UserRoleBO();
         var userRole   = userRoleBO.Get(this.ConnectionHandler, userId, roleId);
         if (userRole == null)
         {
             var operationMenu = new UserRole {
                 UserId = userId, RoleId = roleId
             };
             if (!userRoleBO.Insert(this.ConnectionHandler, operationMenu))
             {
                 throw new Exception("خطایی در ذخیره  نقش کاربر  وجود دارد");
             }
         }
         return(true);
     }
     catch (KnownException ex)
     {
         Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
         throw new KnownException(ex.Message, ex);
     }
     catch (Exception ex)
     {
         Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
         throw new KnownException(ex.Message, ex);
     }
 }
예제 #3
0
        public List <Menu> GetMenuByParentId(Guid menuId, Guid userId)
        {
            List <Guid> roles    = new UserRoleBO().Select(x => x.RoleId, x => x.UserId == userId, true);
            var         roleList = string.Join(",", roles.Select(i => i.ToString()));

            return(new RoleMenuDA().GetMenuByParentId(roleList, menuId));
        }
예제 #4
0
        //VC20140814


        #region Reports common Functions

        /// <summary>
        /// Return users under current role provided
        /// Created By :Dhiraj
        /// Created On :18-Dec-2013
        /// </summary>
        /// <param name="userId">UserId of Current Level</param>
        /// <param name="roleId">RoleId of Current Level</param>
        /// <param name="hierarchyLevelDepth">Difference of currentHierachy and totalHierachy of Current Level</param>
        /// <returns></returns>
        public List <UserRoleBO> GetEmployeesUnderHierarchy(long userId, int roleId, int?teamID, int?hierarchyLevelDepth = null, bool includeParent = false)
        {
            List <UserRoleBO> UserRolesBO = new List <UserRoleBO>();

            foreach (var item in ReportRepository.GetEmployeesUnderHierarchy(userId, roleId, teamID, hierarchyLevelDepth, includeParent))//To fetch only active record
            {
                UserRoleBO objUserRoleBo = new UserRoleBO();
                objUserRoleBo.UserRoleID      = item.UserRoleID;
                objUserRoleBo.RoleID          = item.RoleID;
                objUserRoleBo.UserID          = item.UserID;
                objUserRoleBo.UserName        = item.UserMaster != null ? item.UserMaster.FirstName : string.Empty;
                objUserRoleBo.IsActive        = item.IsActive;
                objUserRoleBo.ProductTypeID   = item.ProductTypeID;
                objUserRoleBo.ProductGroupID  = item.ProductGroupID;
                objUserRoleBo.GeoID           = item.GeoID;
                objUserRoleBo.GeoLevelValue   = item.GeoLevelValue;
                objUserRoleBo.ReportingUserID = item.ReportingUserID;
                objUserRoleBo.CreatedDate     = item.CreatedDate;
                objUserRoleBo.CreatedBy       = item.CreatedBy;
                objUserRoleBo.ModifiedDate    = item.ModifiedDate;
                objUserRoleBo.ModifiedBy      = item.ModifiedBy;
                objUserRoleBo.IsDeleted       = item.IsDeleted;
                UserRolesBO.Add(objUserRoleBo);
            }
            return(UserRolesBO);
        }
        public HttpResponseMessage AddUserRole([FromBody] UserRoleBO userRole)
        {
            UserRoleAndPermissionsDL BL = new UserRoleAndPermissionsDL();
            var result = BL.AddUserRole(userRole);

            return(Request.CreateResponse(HttpStatusCode.OK, result, Configuration.Formatters.JsonFormatter));
        }
        public int UpdateUserRole(UserRoleBO obj)
        {
            try
            {
                int    returnvalue;
                string sql = "update dbo.userroles set rolekey = @rolekey where userkey=@userkey";

                conn = new NpgsqlConnection(connString);
                conn.Open();

                using (var cmd = new NpgsqlCommand(sql, conn))
                {
                    cmd.CommandType = System.Data.CommandType.Text;
                    cmd.Parameters.AddWithValue("userkey", NpgsqlTypes.NpgsqlDbType.Uuid, obj.userkey);
                    cmd.Parameters.AddWithValue("rolekey", NpgsqlTypes.NpgsqlDbType.Uuid, obj.rolekey);
                    returnvalue = cmd.ExecuteNonQuery();
                }

                return(returnvalue);
            }
            catch (Exception msg)
            {
                throw msg;
            }
            finally
            {
                conn.Close();
            }
        }
        public HttpResponseMessage UpdateUserRole([FromBody] UserRoleBO userRole)
        {
            UserRoleAndPermissionsDL BL = new UserRoleAndPermissionsDL();

            var orderdetailCollection = BL.UpdateUserRole(userRole);

            return(Request.CreateResponse(HttpStatusCode.OK, true, Configuration.Formatters.JsonFormatter));
        }
        public List <UserRoleBO> getRoles()
        {
            try
            {
                string            sql      = "SELECT rolekey, descrption FROM dbo.approles  order by descrption asc";
                List <UserRoleBO> rolelist = new List <UserRoleBO>();

                conn = new NpgsqlConnection(connString);
                conn.Open();

                using (var cmd = new NpgsqlCommand(sql, conn))
                {
                    cmd.CommandType = System.Data.CommandType.Text;
                    var reader = cmd.ExecuteReader();
                    do
                    {
                        while (reader.Read())
                        {
                            var BO = new UserRoleBO();
                            BO.rolekey     = Utils.CustomParse <Guid>(reader["rolekey"]);
                            BO.description = Utils.CustomParse <string>(reader["descrption"]);
                            rolelist.Add(BO);
                        }
                    }while (reader.NextResult());
                    reader.Close();
                }

                return(rolelist);
            }
            catch (Exception msg)
            {
                throw msg;
            }
            finally
            {
                conn.Close();
            }
        }
        public UserRoleBO getUserRoleByUserkey(string userkey)
        {
            try
            {
                string sql = "SELECT rolekey, userkey FROM dbo.userroles where userkey=@userkey";
                var    BO  = new UserRoleBO();

                conn = new NpgsqlConnection(connString);
                conn.Open();

                using (var cmd = new NpgsqlCommand(sql, conn))
                {
                    cmd.CommandType = System.Data.CommandType.Text;
                    cmd.Parameters.AddWithValue("userkey", NpgsqlTypes.NpgsqlDbType.Uuid, Guid.Parse(userkey));
                    var reader = cmd.ExecuteReader();
                    do
                    {
                        while (reader.Read())
                        {
                            BO.rolekey = Utils.CustomParse <Guid>(reader["rolekey"]);
                            BO.userkey = Utils.CustomParse <Guid>(reader["userkey"]);
                        }
                    }while (reader.NextResult());
                    reader.Close();
                }

                return(BO);
            }
            catch (Exception msg)
            {
                throw msg;
            }
            finally
            {
                conn.Close();
            }
        }