Exemplo n.º 1
0
        /// <summary>
        /// 添加友情链接
        /// </summary>
        public string AddFriendlyLink(FriendlyLink friendlyLink)
        {
            string result = "添加失败";

            var conn = DBRepository.GetSqlConnection();
            try
            {
                conn.Open();
                if (friendlyLink != null)
                {
                    if (!string.IsNullOrEmpty(friendlyLink.Name) &&
                        !string.IsNullOrEmpty(friendlyLink.Link) &&
                        friendlyLink.Sort > 0)
                    {
                        FriendlyLink temp = DBRepository.SelectOne<FriendlyLink>("Id", friendlyLink.Id, conn);
                        conn.Close();
                        conn.Open();
                        if (temp == null)
                        {
                            List<string> filterColumns = new List<string>() { "Id" };
                            if (DBRepository.Insert<FriendlyLink>(friendlyLink, conn, filterColumns))
                            {
                                result = "success";
                            }
                        }
                    }
                }
                else
                {
                    result = "friendlyLink对象为空";
                    LogService.Log("FriendlyLinkService.AddFriendlyLink", "friendlyLink对象为空");
                }
            }
            catch (Exception e)
            {
                result = "程序出现异常,详情见日志";
                LogService.Log("添加友情链接", e.ToString());
            }
            finally
            {
                conn.Close();
            }

            return result;
        }
Exemplo n.º 2
0
        public ActionResult AddFriendlyLink(FriendlyLink friendlyLink)
        {
            if (Session["UserId"] == null)
            {
                return Redirect("/admin/login");
            }

            if (friendlyLink != null)
            {
                if (!string.IsNullOrEmpty(friendlyLink.Name) &&
                    !string.IsNullOrEmpty(friendlyLink.Link) &&
                    friendlyLink.Sort > 0)
                {
                    FriendlyLinkService friendlyLinkService = new FriendlyLinkService();
                    friendlyLinkService.AddFriendlyLink(friendlyLink);
                    WitBird.Sex.Web.Cache.UpdateFriendlyLinks();//更新缓存
                }
            }

            return Redirect(Request.UrlReferrer.AbsoluteUri);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 更新友情链接
        /// </summary>
        public string EditFriendlyLink(FriendlyLink friendlyLink)
        {
            string result = "更新失败";

            var conn = DBRepository.GetSqlConnection();
            try
            {
                conn.Open();
                if (friendlyLink != null)
                {
                    if (friendlyLink.Id > 0 &&
                        !string.IsNullOrEmpty(friendlyLink.Name) &&
                        !string.IsNullOrEmpty(friendlyLink.Link) &&
                        friendlyLink.Sort > 0)
                    {
                        if (DBRepository.Update<FriendlyLink>(friendlyLink, "Id", conn))
                        {
                            result = "success";
                        }
                    }
                }
                else
                {
                    result = "friendlyLink对象为空";
                    LogService.Log("FriendlyLinkService.EditFriendlyLink", "friendlyLink对象为空");
                }
            }
            catch (Exception e)
            {
                result = "程序出现异常,详情见日志";
                LogService.Log("更新友情链接", e.ToString());
            }
            finally
            {
                conn.Close();
            }

            return result;
        }