Пример #1
0
        /// <summary>
        /// Put datarow raw values to entity object
        /// </summary>
        /// <param name="dr"></param>
        /// <returns></returns>
        protected CmsPageSecurityZoneUserRole fromDataRow(DataRow dr)
        {
            CmsPageSecurityZoneUserRole entity = new CmsPageSecurityZoneUserRole();

            entity.ZoneId      = Convert.ToInt32(dr["ZoneId"]);
            entity.UserRoleId  = Convert.ToInt32(dr["UserRoleId"]);
            entity.ReadAccess  = Convert.ToBoolean(dr["ReadAccess"]);
            entity.WriteAccess = Convert.ToBoolean(dr["WriteAccess"]);
            return(entity);
        }
 /// <summary>
 /// Insert into `ZoneUserRole`
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 public bool insert(CmsPageSecurityZoneUserRole entity)
 {
     try
     {
         repository.Save(entity);
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Пример #3
0
        /// <summary>
        /// Insert into `ZoneUserRole`
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public bool insert(CmsPageSecurityZoneUserRole entity)
        {
            StringBuilder sql = new StringBuilder("INSERT INTO ");

            sql.Append(TABLE_NAME);
            sql.Append(" (ZoneId,UserRoleId,ReadAccess,WriteAccess) VALUES (");
            sql.Append(entity.ZoneId.ToString() + ",");
            sql.Append(entity.UserRoleId.ToString() + ",");
            sql.Append(entity.ReadAccessAsInt.ToString() + ",");
            sql.Append(entity.WriteAccessAsInt.ToString() + ");");

            int affected = this.RunUpdateQuery(sql.ToString());

            if (affected > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #4
0
        /// <summary>
        /// Bulk insert into `ZoneUserRole`
        /// </summary>
        /// <param name="entityList"></param>
        /// <returns></returns>
        public bool insert(List <CmsPageSecurityZoneUserRole> entityList)
        {
            if (entityList.Count == 0)
            {
                return(true);
            }

            StringBuilder sql = new StringBuilder("INSERT INTO ");

            sql.Append(TABLE_NAME);
            sql.Append(" (ZoneId,UserRoleId,ReadAccess,WriteAccess) VALUES ");

            for (int x = 0; x < entityList.Count; x++)
            {
                CmsPageSecurityZoneUserRole g = entityList[x];
                sql.Append("(" + g.ZoneId.ToString() + "," + g.UserRoleId.ToString() + "," + g.ReadAccessAsInt.ToString() + "," + g.WriteAccessAsInt.ToString() + ")");
                if (x + 1 < entityList.Count)
                {
                    sql.Append(",");
                }
                else
                {
                    sql.Append(";");
                }
            }

            int affected = this.RunUpdateQuery(sql.ToString());

            if (affected == entityList.Count)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }