示例#1
0
        /// <summary>
        /// 更新广告信息
        /// </summary>
        /// <param name="ActivityType">活动类型</param>
        /// <param name="ActivityId">活动编号</param>
        /// <param name="Cover">广告图片</param>
        /// <param name="ShowStatus">显示状态</param>
        /// <param name="ShowPlatform">显示平台</param>
        /// <returns></returns>
        public IntegralMallAdInfo UpdateAdInfo(IntegralMallAdInfo.AdActivityType ActivityType, long ActivityId, string Cover, IntegralMallAdInfo.AdShowStatus?ShowStatus, IntegralMallAdInfo.AdShowPlatform?ShowPlatform)
        {
            int adtype = ActivityType.GetHashCode();
            var data   = DbFactory.Default.Get <IntegralMallAdInfo>().Where(d => d.ActivityType == adtype).FirstOrDefault();

            if (data == null)
            {
                data = new IntegralMallAdInfo();
                data.ShowAdStatus = IntegralMallAdInfo.AdShowStatus.Show;
            }
            else
            {
                if (data.ActivityId == ActivityId)
                {
                    if (data.ShowAdStatus == IntegralMallAdInfo.AdShowStatus.Hide)
                    {
                        data.ShowAdStatus = IntegralMallAdInfo.AdShowStatus.Show;
                    }
                    else
                    {
                        data.ShowAdStatus = IntegralMallAdInfo.AdShowStatus.Hide;
                    }
                }
                else
                {
                    data.ShowAdStatus = IntegralMallAdInfo.AdShowStatus.Show;
                }
            }
            data.ActivityType   = adtype;
            data.ActivityId     = ActivityId;
            data.Cover          = Cover;
            data.ShowAdPlatform = ShowPlatform;
            DbFactory.Default.Save(data);
            return(data);
        }
示例#2
0
        /// <summary>
        /// 获取广告配置
        /// </summary>
        /// <param name="adtype">活动类型</param>
        /// <param name="adplatform">显示平台</param>
        /// <returns></returns>
        public IntegralMallAdInfo GetAdInfo(IntegralMallAdInfo.AdActivityType adtype, IntegralMallAdInfo.AdShowPlatform adplatform)
        {
            int sadtype               = adtype.GetHashCode();
            int sadplatform           = adplatform.GetHashCode();
            int sstatus               = IntegralMallAdInfo.AdShowStatus.Show.GetHashCode();
            IntegralMallAdInfo result = Context.IntegralMallAdInfo.FirstOrDefault(d => d.ActivityType == sadtype && d.ShowPlatform == sadplatform && d.ShowStatus == sstatus);

            return(result);
        }
示例#3
0
        /// <summary>
        /// 获取广告配置
        /// </summary>
        /// <param name="adtype">活动类型</param>
        /// <param name="adplatform">显示平台</param>
        /// <returns></returns>
        public IntegralMallAdInfo GetAdInfo(IntegralMallAdInfo.AdActivityType adtype, IntegralMallAdInfo.AdShowPlatform adplatform)
        {
            int sadtype               = adtype.GetHashCode();
            int sadplatform           = adplatform.GetHashCode();
            int sstatus               = IntegralMallAdInfo.AdShowStatus.Show.GetHashCode();
            IntegralMallAdInfo result = DbFactory.Default.Get <IntegralMallAdInfo>().Where(d => d.ActivityType == sadtype && d.ShowPlatform == sadplatform && d.ShowStatus == sstatus).FirstOrDefault();

            if (result != null)
            {
                var nowdate = DateTime.Now;
                var isExist = DbFactory.Default.Get <WeiActivityInfoInfo>().Where(d => d.Id == result.ActivityId && d.EndTime > nowdate && d.BeginTime <= nowdate).Exist();
                if (!isExist)
                {
                    return(null);
                }
            }
            return(result);
        }
示例#4
0
        /// <summary>
        /// 更新广告信息
        /// </summary>
        /// <param name="ActivityType">活动类型</param>
        /// <param name="ActivityId">活动编号</param>
        /// <param name="Cover">广告图片</param>
        /// <param name="ShowStatus">显示状态</param>
        /// <param name="ShowPlatform">显示平台</param>
        /// <returns></returns>
        public IntegralMallAdInfo UpdateAdInfo(IntegralMallAdInfo.AdActivityType ActivityType, long ActivityId, string Cover, IntegralMallAdInfo.AdShowStatus?ShowStatus, IntegralMallAdInfo.AdShowPlatform?ShowPlatform)
        {
            IntegralMallAdInfo data = new IntegralMallAdInfo();
            int adtype = ActivityType.GetHashCode();

            data = Context.IntegralMallAdInfo.FirstOrDefault(d => d.ActivityType == adtype);
            bool isadd = false;

            if (data == null)
            {
                data              = new IntegralMallAdInfo();
                isadd             = true;
                data.ShowAdStatus = IntegralMallAdInfo.AdShowStatus.Show;
            }
            else
            {
                if (data.ActivityId == ActivityId)
                {
                    if (data.ShowAdStatus == IntegralMallAdInfo.AdShowStatus.Hide)
                    {
                        data.ShowAdStatus = IntegralMallAdInfo.AdShowStatus.Show;
                    }
                    else
                    {
                        data.ShowAdStatus = IntegralMallAdInfo.AdShowStatus.Hide;
                    }
                }
                else
                {
                    data.ShowAdStatus = IntegralMallAdInfo.AdShowStatus.Show;
                }
            }
            data.ActivityType   = adtype;
            data.ActivityId     = ActivityId;
            data.Cover          = Cover;
            data.ShowAdPlatform = ShowPlatform;
            if (isadd)
            {
                Context.IntegralMallAdInfo.Add(data);
            }
            Context.SaveChanges();
            return(data);
        }