Esempio n. 1
0
        /// <summary>
        /// 删除用户
        /// </summary>
        /// <returns></returns>
        public int DeleteData(string id)
        {
            AdRelationModel adRelationInfo = new AdRelationModel();

            adRelationInfo.AdId = id;
            return(GenerateDal.Delete <AdRelationModel>(CommonSqlKey.DeleteAdRelation, adRelationInfo));
        }
Esempio n. 2
0
        public int UpdateData(AdModel adInfo)
        {
            try
            {
                GenerateDal.BeginTransaction();
                string userClientId = HttpContextHandler.GetHeaderObj("UserClientId").ToString();
                if (string.IsNullOrEmpty(userClientId))
                {
                    return(0);
                }
                adInfo.ClientId = userClientId;
                GenerateDal.Update(CommonSqlKey.UpdateAd, adInfo);
                new AdRelationService().DeleteData(adInfo.Id.ToString());
                if (adInfo.Reources != null && adInfo.Reources.Count > 0)
                {
                    foreach (var item in adInfo.Reources)
                    {
                        var tmpInfo = new AdRelationModel();
                        tmpInfo.AdId     = adInfo.Id;
                        tmpInfo.SourceId = item.PicId;
                        new AdRelationService().PostAdRelationData(tmpInfo);
                    }
                }
                GenerateDal.CommitTransaction();

                return(1);
            }
            catch (Exception e)
            {
                GenerateDal.RollBack();
                return(0);
            }
        }
Esempio n. 3
0
        public ResultObj <List <AdRelationModel> > GetRelationByIdAndType(string adId, int adType = 0)
        {
            AdRelationModel adRelationInfo = new AdRelationModel();

            adRelationInfo.AdId   = adId;
            adRelationInfo.AdType = adType;
            IAdRelation _iRelation = new AdRelationService();
            var         adRelation = _iRelation.GetRelationByIdAndType(adRelationInfo);

            return(Content(adRelation));
        }
Esempio n. 4
0
        public List <AdRelationModel> GetRelationByIdAndType(AdRelationModel adRelationInfo)
        {
            var conditions = new List <Condition>();

            conditions.Add(new Condition
            {
                LeftBrace    = " AND ",
                ParamName    = "AdId",
                DbColumnName = "a.ad_id",
                ParamValue   = adRelationInfo.AdId,
                Operation    = ConditionOperate.Equal,
                RightBrace   = "",
                Logic        = ""
            });
            if (adRelationInfo.AdType != 0)
            {
                conditions.Add(new Condition
                {
                    LeftBrace    = " AND ",
                    ParamName    = "AdType",
                    DbColumnName = "a.ad_type",
                    ParamValue   = adRelationInfo.AdType,
                    Operation    = ConditionOperate.Equal,
                    RightBrace   = "",
                    Logic        = ""
                });
            }

            conditions.Add(new Condition
            {
                LeftBrace    = "  ",
                ParamName    = "ResourceUrl",
                DbColumnName = "",
                ParamValue   = ConfigHandler.ResourceUrl,
                Operation    = ConditionOperate.None,
                RightBrace   = "",
                Logic        = ""
            });

            conditions.Add(new Condition
            {
                LeftBrace    = "  ",
                ParamName    = "Sequence",
                DbColumnName = "sequence",
                ParamValue   = "asc",
                Operation    = ConditionOperate.OrderBy,
                RightBrace   = "",
                Logic        = ""
            });

            return(GenerateDal.LoadByConditions <AdRelationModel>(CommonSqlKey.GetRelationByIdAndType, conditions));
        }
Esempio n. 5
0
        public int PostAdRelationData(AdRelationModel adRelationInfo)
        {
            try
            {
                GenerateDal.BeginTransaction();

                GenerateDal.Create(adRelationInfo);
                GenerateDal.CommitTransaction();

                return(1);
            }
            catch (Exception e)
            {
                GenerateDal.RollBack();
                return(0);
            }
        }