Ejemplo n.º 1
0
        public async Task EditPuzzleGroup(Request request, Response response)
        {
            var userSession = await CheckAuth.Check(request, response, AuthLevel.Organizer);

            if (userSession == null)
            {
                return;
            }

            var requestJson = request.Json <EditPuzzleGroupRequest>();

            //判断请求是否有效
            if (!Validation.Valid(requestJson, out string reason))
            {
                await response.BadRequest(reason);

                return;
            }

            //生成修改后对象
            var updatePg = new puzzle_group
            {
                pgid    = requestJson.pgid,
                pg_name = requestJson.pg_name,
                pg_desc = requestJson.pg_desc,
                is_hide = (byte)(requestJson.is_hide == 1 ? 1 : 0)
            };

            var pgDb = DbFactory.Get <PuzzleGroup>();
            await pgDb.SimpleDb.AsUpdateable(updatePg).ExecuteCommandAsync();

            await pgDb.InvalidateCache();

            await response.OK();
        }
Ejemplo n.º 2
0
 public PuzzleGroupView(puzzle_group pg)
 {
     pgid       = pg.pgid;
     pg_name    = pg.pg_name;
     is_hide    = pg.is_hide;
     difficulty = pg.difficulty;
 }