public ActionResult Toggle(int id, bool state)
        {
            Links link = LinksService.GetById(id);

            link.Status = !state ? Status.Available : Status.Unavailable;
            bool b = LinksService.SaveChanges() > 0;

            return(ResultData(null, b, b ? "切换成功!" : "切换失败!"));
        }
        public ActionResult ToggleRecommend(int id, bool state)
        {
            Links link = LinksService.GetById(id);

            link.Recommend = !state;
            bool b = LinksService.SaveChanges() > 0;

            return(ResultData(null, b, b ? "切换成功!" : "切换失败!"));
        }
示例#3
0
        public ActionResult ToggleWhitelist(int id, bool state)
        {
            Links link = LinksService.GetById(id);

            link.Except = !state;
            bool b = LinksService.UpdateEntitySaved(link);

            return(ResultData(null, b, b ? "切换成功!" : "切换失败!"));
        }
        public ActionResult Edit(Links model)
        {
            Links links = LinksService.GetById(model.Id);

            links.Name = model.Name;
            links.Url  = model.Url;
            bool b = LinksService.SaveChanges() > 0;

            return(ResultData(null, b, b ? "保存成功" : "保存失败"));
        }
示例#5
0
        public ActionResult Edit(Links model)
        {
            Links links = LinksService.GetById(model.Id);

            links.Name = model.Name;
            links.Url  = model.Url;
            bool b = LinksService.UpdateEntitySaved(links);

            return(ResultData(null, b, b ? "保存成功" : "保存失败"));
        }
        public ActionResult Add(Links links)
        {
            var  entry = LinksService.GetById(links.Id);
            bool b;

            if (entry is null)
            {
                b = LinksService.AddEntitySaved(links) != null;
            }
            else
            {
                entry.Url       = links.Url;
                entry.Except    = links.Except;
                entry.Name      = links.Name;
                entry.Recommend = links.Recommend;
                b = LinksService.SaveChanges() > 0;
            }

            return(b ? ResultData(null, message: "添加成功!") : ResultData(null, false, "添加失败!"));
        }