Exemple #1
0
        public static Task ChangePin(IOwinContext ctx)
        {
            if (!Authentication.Check(ctx))
            {
                return(ctx.Error(403));
            }

            var args = ctx.Parse();

            if (Validator.GetGuid(args["id"]) == null)
            {
                return(ctx.Missing("id"));
            }
            if (args["newpin"] == null)
            {
                return(ctx.Missing("newpin"));
            }

            JObject response = database.Users.ChangePin(args);

            if (response != null)
            {
                return(ctx.JSON(response));
            }

            return(ctx.Error());
        }
Exemple #2
0
        public static Task CancelBet(IOwinContext ctx)
        {
            if (!Authentication.Check(ctx))
            {
                return(ctx.Error(403));
            }

            var args = ctx.Parse();

            if (Validator.GetGuid(args["game_id"]) == null)
            {
                return(ctx.Error(401));
            }

            if (Validator.GetGuid(args["user_id"]) == null)
            {
                return(ctx.Error(401));
            }


            if (args["coin"] == null)
            {
                return(ctx.Error(401));
            }


            if (database.Games.Cancelbet(args))
            {
                return(ctx.OK());
            }
            else
            {
                return(ctx.Error(400));
            }
        }
Exemple #3
0
        public static Task Start(IOwinContext ctx)
        {
            //t.Change(0, 1000 * 60 * 1);

            if (!Authentication.Check(ctx))
            {
                return(ctx.Error(403));
            }

            var args = ctx.Parse();


            if (database.Games.Start(args))
            {
                JObject response = new JObject();

                response["seconds"] = crm.RouletBackground.Instance.GetSeconds();

                response["time"] = Validator.CurentUnixTime();

                return(ctx.JSON(response));
            }
            else
            {
                return(ctx.Error(400));
            }
        }
Exemple #4
0
        public static Task Log(IOwinContext ctx)
        {
            if (!Authentication.Check(ctx))
            {
                return(ctx.Error(403));
            }

            var args = ctx.Parse();

            if (Validator.GetGuid(args["user_id"]) == null)
            {
                return(ctx.Error(401));
            }

            if (args["coin"] == null)
            {
                return(ctx.Error(401));
            }

            if (args["type"] == null)
            {
                return(ctx.Error(401));
            }

            if (database.Logs.Log(args))
            {
                return(ctx.OK());
            }
            else
            {
                return(ctx.Error(400));
            }
        }
Exemple #5
0
        public static Task Create(IOwinContext ctx)
        {
            if (!Authentication.Check(ctx))
            {
                return(ctx.Error(403));
            }

            var args = ctx.Parse();

            Guid?id = database.Users.Create(args);

            if (id != null)
            {
                return(ctx.OK());
            }
            else
            {
                return(ctx.Error(400));
            }
        }
Exemple #6
0
        public static Task List(IOwinContext ctx)
        {
            if (!Authentication.Check(ctx))
            {
                return(ctx.Error(403));
            }

            JArray games = database.Games.List();

            return(ctx.JSON(games));
        }
Exemple #7
0
        public static Task SaveDrawDetails(IOwinContext ctx)
        {
            if (!Authentication.Check(ctx))
            {
                return(ctx.Error(403));
            }
            var args = ctx.Parse();

            database.Games.SaveDrawDetails(args);
            return(ctx.JSON(true));
        }
Exemple #8
0
        public static Task ReceiveTransferredPoints(IOwinContext ctx)
        {
            if (!Authentication.Check(ctx))
            {
                return(ctx.Error(403));
            }
            var args = ctx.Parse();

            int details = database.Games.ReceiveTransferredPoints(args);

            return(ctx.JSON(details));
        }
Exemple #9
0
        public static Task delete(IOwinContext ctx)
        {
            if (!Authentication.Check(ctx))
            {
                return(ctx.Error(403));
            }

            var args = ctx.Parse();

            if (Validator.GetGuid(args["id"]) == null)
            {
                return(ctx.Missing("id"));
            }

            if (database.Users.Delete(args))
            {
                return(ctx.OK());
            }

            return(ctx.Error());
        }
Exemple #10
0
        public static Task GetReceivables(IOwinContext ctx)
        {
            if (!Authentication.Check(ctx))
            {
                return(ctx.Error(403));
            }
            string userid = Convert.ToString(ctx.Parametr("userid"));
            string gameid = Convert.ToString(ctx.Parametr("gameid"));

            JArray details = database.Games.GetRecievables(userid, gameid);

            return(ctx.JSON(details));
        }
Exemple #11
0
        public static Task UpdateLatFive(IOwinContext ctx)
        {
            if (!Authentication.Check(ctx))
            {
                return(ctx.Error(403));
            }

            var args = ctx.Parse();

            if (args["last"] == null)
            {
                return(ctx.Error(401));
            }

            if (database.Games.UpdateLastFive(args))
            {
                return(ctx.OK());
            }
            else
            {
                return(ctx.Error(400));
            }
        }
Exemple #12
0
        public static Task TransferWinningPoints(IOwinContext ctx)
        {
            if (!Authentication.Check(ctx))
            {
                return(ctx.Error(403));
            }
            var args   = ctx.Parse();
            var userid = args["user_id"].ToString();



            database.Games.TransferWiningPoints(userid);
            return(ctx.JSON(true));
        }
Exemple #13
0
        public static Task Find(IOwinContext ctx)
        {
            if (!Authentication.Check(ctx))
            {
                return(ctx.Error(403));
            }

            var args = ctx.Parse();

            Guid?id = Validator.GetGuid(args["id"]);

            JObject game = database.Games.Find(id);

            return(ctx.JSON(game));
        }
Exemple #14
0
        public static Task GetDistrict(IOwinContext ctx)
        {
            if (!Authentication.Check(ctx))
            {
                return(ctx.Error(403));
            }
            var args = ctx.Parse();

            int stateid = args.Value <Int32>("stateid");


            List <SelectListItem> users = database.Users.GetDistrictByState(stateid);

            return(ctx.JSON(users));
        }
Exemple #15
0
        public static Task Binded(IOwinContext ctx)
        {
            if (!Authentication.Check(ctx))
            {
                return(ctx.Error(403));
            }

            Guid?id = Validator.GetGuid(ctx.Parametr("id"));

            int?level = Convert.ToInt32(ctx.Parametr("level"));

            JObject users = database.Users.Binded(id, level);

            return(ctx.JSON(users));
        }
Exemple #16
0
        public static Task Register(IOwinContext ctx)
        {
            var args = ctx.Parse();

            Guid?id = database.Users.Create(args);

            if (id != null)
            {
                return(ctx.OK());
            }
            else
            {
                return(ctx.Error(400));
            }
        }
Exemple #17
0
        public static Task CreateLedger(IOwinContext ctx)
        {
            if (!Authentication.Check(ctx))
            {
                return(ctx.Error(403));
            }

            string userid       = Convert.ToString(ctx.Parametr("userid"));
            int    credit       = Convert.ToInt32(ctx.Parametr("credit"));
            int    debit        = Convert.ToInt32(ctx.Parametr("debit"));
            int    access_level = Convert.ToInt32(ctx.Parametr("access_level"));

            var result = database.Users.CreateLedger(userid, credit, debit, access_level);


            return(ctx.JSON(result));
        }
Exemple #18
0
        public static Task List(IOwinContext ctx)
        {
            if (!Authentication.Check(ctx))
            {
                return(ctx.Error(403));
            }

            int?level = Convert.ToInt32(ctx.Parametr("level"));

            if (level == null)
            {
                level = 0;
            }

            JObject users = database.Users.List(level);

            return(ctx.JSON(users));
        }
Exemple #19
0
        public static Task Get(IOwinContext ctx)
        {
            //if (!Authentication.Check(ctx))
            //{
            //    return ctx.Error(403);
            //}
            var args = ctx.Parse();

            if (Validator.GetGuid(args["id"]) == null)
            {
                return(ctx.Error(401));
            }

            var userid = Guid.Parse(args["id"].ToString());


            JObject user = database.Users.Find(userid);

            return(ctx.JSON(user));
        }
Exemple #20
0
        public static Task Filter(IOwinContext ctx)
        {
            if (!Authentication.Check(ctx))
            {
                return(ctx.Error(403));
            }

            int?state        = Convert.ToInt32(ctx.Parametr("state"));
            int?districtid   = Convert.ToInt32(ctx.Parametr("districtid"));
            int?access_level = Convert.ToInt32(ctx.Parametr("access_level"));


            if (state == null)
            {
                state = 0;
            }

            JObject users = database.Users.Filter(state, districtid, access_level);

            return(ctx.JSON(users));
        }
Exemple #21
0
        public static Task List(IOwinContext ctx)
        {
            if (!Authentication.Check(ctx))
            {
                return(ctx.Error(403));
            }

            int start = Validator.CurentUnixTime();

            if (ctx.Parametr("start") != null)
            {
                start = Convert.ToInt32(ctx.Parametr("start"));
            }

            JArray list = database.Logs.List(start);

            JObject response = new JObject();

            response["data"] = list;

            return(ctx.JSON(response));
        }
Exemple #22
0
        public static Task FindInfo(IOwinContext ctx)
        {
            if (!Authentication.Check(ctx))
            {
                return(ctx.Error(403));
            }

            var args = ctx.Parse();

            Guid?id = Validator.GetGuid(args["id"]);

            JArray game = database.Games.FindGame(id);

            JObject response = new JObject();

            response["data"] = game;

            response["seconds"] = crm.RouletBackground.Instance.GetSeconds();

            response["time"] = Validator.CurentUnixTime();

            return(ctx.JSON(response));
        }