示例#1
0
        public TaskModel CreateTask(TaskModel model)
        {
            var x = db.Task.Add(model);

            db.SaveChanges();
            return(x.Entity);
        }
示例#2
0
        public GameModel CreateGame(GameModel model)
        {
            model.Hidden = false;
            var x = db.Game.Add(model);

            db.SaveChanges();
            return(x.Entity);
        }
        public PlayerGameModel ParticipateGame(int gameId, string userId)
        {
            PlayerGameModel model = new PlayerGameModel();

            model.GameId        = gameId;
            model.PlayerId      = userId;
            model.state         = "undefined";
            model.ToolVmCreated = false;
            var x = db.PlayerGame.Add(model);

            db.SaveChanges();
            return(x.Entity);
        }
示例#4
0
        public async Task <PlayerTaskModel> CreatePlayerTaskAsync(int taskId, int gameId, CyberSparrow user)
        {
            var task = th.GetTask(taskId);
            var game = gh.GetGame(gameId);

            if (task == null || game == null)
            {
                throw new NullReferenceException("GAME OR TASK IS NULL");
            }
            PlayerTaskModel model = new PlayerTaskModel();

            model.Game = game;
            model.Task = task;
            model.User = user;
            model.NumberOfFailedflags = 0;
            model.TaskState           = "ready";
            var m = await db.PlayerTask.AddAsync(model);

            db.SaveChanges();
            return(m.Entity);
        }
示例#5
0
 public bool SaveChanges()
 {
     return(db.SaveChanges() > 0);
 }