Exemplo n.º 1
0
        public async Task <ActionResult> ToggleWhitelist(int id, bool state)
        {
            Links link = await LinksService.GetByIdAsync(id);

            link.Except = !state;
            bool b = await LinksService.SaveChangesAsync() > 0;

            return(ResultData(null, b, b ? "切换成功!" : "切换失败!"));
        }
Exemplo n.º 2
0
        public async Task <ActionResult> Toggle(int id, bool state)
        {
            Links link = await LinksService.GetByIdAsync(id);

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

            return(ResultData(null, b, b ? "切换成功!" : "切换失败!"));
        }
Exemplo n.º 3
0
        public async Task <ActionResult> Edit(Links model)
        {
            Links links = await LinksService.GetByIdAsync(model.Id);

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

            return(ResultData(null, b, b ? "保存成功" : "保存失败"));
        }
Exemplo n.º 4
0
        public async Task <ActionResult> Add(Links links)
        {
            var entry = await LinksService.GetByIdAsync(links.Id);

            bool b;

            if (entry is null)
            {
                b = await LinksService.AddEntitySavedAsync(links) > 0;
            }
            else
            {
                entry.Url       = links.Url;
                entry.Except    = links.Except;
                entry.Name      = links.Name;
                entry.Recommend = links.Recommend;
                b = await LinksService.SaveChangesAsync() > 0;
            }

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