Example #1
0
        public static bool SetItem(SiteSeoSettingModels item)
        {
            SQLData.Database    db       = new SQLData.Database(WebInfo.Conn);
            SQLData.TableObject tableObj = db.GetTableObject("SiteSeoSetting");
            tableObj.GetDataFromObject(item);
            DateTime now = DateTime.Now;
            string   sql = $"SELECT * FROM SiteSeoSetting WHERE  SiteID='{ item.SiteID }' ";

            bool isNew = db.GetFirstValue(sql) == null;

            if (isNew)
            {
                tableObj["Creator"]    = Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id;
                tableObj["CreateTime"] = now;
                tableObj["Modifier"]   = WorkV3.Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id;
                tableObj["ModifyTime"] = now;
                tableObj.Insert();
            }
            else
            {
                tableObj.Remove("SiteID");
                tableObj.Remove("Creator");
                tableObj.Remove("CreateTime");
                if (string.IsNullOrEmpty(item.Title))
                {
                    tableObj["Title"] = "";
                }
                if (string.IsNullOrEmpty(item.Description))
                {
                    tableObj["Description"] = "";
                }
                if (string.IsNullOrEmpty(item.Author))
                {
                    tableObj["Author"] = "";
                }
                if (string.IsNullOrEmpty(item.Copyright))
                {
                    tableObj["Copyright"] = "";
                }
                if (string.IsNullOrEmpty(item.Keywords))
                {
                    tableObj["Keywords"] = "";
                }
                if (string.IsNullOrEmpty(item.GA))
                {
                    tableObj["GA"] = "";
                }
                if (string.IsNullOrEmpty(item.GTM))
                {
                    tableObj["GTM"] = "";
                }
                if (string.IsNullOrEmpty(item.Baidu))
                {
                    tableObj["Baidu"] = "";
                }
                if (string.IsNullOrEmpty(item.Alexa))
                {
                    tableObj["Alexa"] = "";
                }
                if (string.IsNullOrEmpty(item.GoogleSearch))
                {
                    tableObj["GoogleSearch"] = "";
                }
                if (string.IsNullOrEmpty(item.BaiduMA))
                {
                    tableObj["BaiduMA"] = "";
                }
                if (string.IsNullOrEmpty(item.Bing))
                {
                    tableObj["Bing"] = "";
                }
                if (string.IsNullOrEmpty(item.ExtraCode))
                {
                    tableObj["ExtraCode"] = "";
                }

                tableObj["Modifier"]   = WorkV3.Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id;
                tableObj["ModifyTime"] = now;
                tableObj.Update(item.SiteID);
            }
            return(true);
        }