Пример #1
0
        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 ? "切换成功!" : "切换失败!"));
        }
Пример #2
0
        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 ? "切换成功!" : "切换失败!"));
        }
Пример #4
0
        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 ? "保存成功" : "保存失败"));
        }
Пример #6
0
        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, "添加失败!"));
        }