示例#1
0
        private async System.Threading.Tasks.Task updateTimeAsync(GamePosts gp)
        {
            try
            {
                //var game = await new GamesRepository().GetGameDetail(c.GameSn);
                CSGOMatches.RootObject getm = await new CSGORepository().GetCSGOMatches((int)gp.AutoSn);


                //更新時間日期


                if (gp.edate != getm.begin_at)
                {
                    var gpm = await new gameController().AutoEdit(gp.sn);
                    gpm.gamepost.edate = getm.begin_at;
                    gpm.game.edate     = getm.begin_at;
                    gpm.game.gamedate  = getm.begin_at;
                    foreach (var t in gpm.game.topicList)
                    {
                        t.edate = getm.begin_at;
                    }
                    await new gameController().AutoEdit(gpm);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
示例#2
0
        public ActionResult DeleteConfirmed(int id)
        {
            GamePosts gamePosts = db.GamePosts.Find(id);

            db.GamePosts.Remove(gamePosts);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#3
0
        public void add(GamePosts gp)
        {
            gp.inpdate = DateTime.Now;
            gp.valid   = 1;
            db.GamePosts.Add(gp);

            db.SaveChanges();
        }
示例#4
0
 public ActionResult Edit([Bind(Include = "sn,GameSn,VedioRecordSn,valid,inpdate")] GamePosts gamePosts)
 {
     if (ModelState.IsValid)
     {
         db.Entry(gamePosts).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(gamePosts));
 }
 public GamePostViewModel()
 {
     vedio    = new VedioRecord();
     gamepost = new GamePosts();
     game     = new gameDto();
     cfgVedio = new cfgVedio();
     TeamA    = new Teams();
     TeamB    = new Teams();
     PlayGame = new cfgPlayGame();
 }
示例#6
0
        public ActionResult Create([Bind(Include = "sn,GameSn,VedioRecordSn,valid,inpdate")] GamePosts gamePosts)
        {
            if (ModelState.IsValid)
            {
                db.GamePosts.Add(gamePosts);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(gamePosts));
        }
示例#7
0
        // GET: GamePosts/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            GamePosts gamePosts = db.GamePosts.Find(id);

            if (gamePosts == null)
            {
                return(HttpNotFound());
            }
            return(View(gamePosts));
        }
示例#8
0
        public void update(GamePosts gp)
        {
            GamePosts gpd = db.GamePosts.Where(p => p.sn == gp.sn).FirstOrDefault();

            gpd.VedioRecordSn = gp.VedioRecordSn;
            gpd.GameSn        = gp.GameSn;
            gpd.TeamASn       = gp.TeamASn;
            gpd.TeamBSn       = gp.TeamBSn;
            gpd.sdate         = gp.sdate;
            gpd.edate         = gp.edate;
            gpd.PlayGameSn    = gp.PlayGameSn;
            gpd.Visited       = gp.Visited;
            gpd.LiveCount     = gp.LiveCount;
            db.SaveChanges();
        }
        public async System.Threading.Tasks.Task <string> Create(GamePostViewModel gpvm)
        {
            ControllerContext.HttpContext.Response.Headers.Add("Access-Control-Allow-Origin", "*");
            try
            {
                var vedio = new VedioRecord();
                if (gpvm.vedio == null)
                {
                    gpvm.vedio = vedio;
                }


                if (gpvm.livename == "1")
                {
                    gpvm.vedio.vediourl   = "https://www.twitch.tv/" + gpvm.live;
                    gpvm.vedio.cfgVedioSn = 4;
                }
                else if (gpvm.livename == "2")
                {
                    gpvm.vedio.vediourl   = gpvm.live;
                    gpvm.vedio.cfgVedioSn = 5;
                }
                else
                {
                    gpvm.vedio.cfgVedioSn = 0;
                }

                // gpvm.vedio = vedio;
                gpvm.vedio.title    = (string.IsNullOrEmpty(gpvm.vedio.title) ? "" : gpvm.vedio.title);
                gpvm.vedio.comment  = (string.IsNullOrEmpty(gpvm.vedio.comment) ? "" : gpvm.vedio.comment);
                gpvm.vedio.vediourl = (string.IsNullOrEmpty(gpvm.vedio.vediourl) ? "" : gpvm.vedio.vediourl);
                gpvm.vedio.valid    = 1;
                gpvm.vedio.inpdate  = DateTime.Now;
                gpvm.vedio.live     = gpvm.live;
                List <cfgVedio> cvList = new cfgVedioRepository().getAll();


                VedioRecordRepository vrr = new VedioRecordRepository();
                vrr.add(gpvm.vedio);



                gameDto game = gpvm.game;
                //game.userId = User.Identity.GetUserId();
                game.comSn    = 1;
                game.sdate    = DateTime.Now;
                game.edate    = DateTime.Now.AddYears(100);
                game.gamedate = DateTime.Now.AddYears(100);
                game.betModel = 2;
                game.rake     = 10;
                game          = await new GamesRepository().CreateLive(game);

                GamePosts gp = new GamePosts {
                    GameSn = game.sn, valid = 1, inpdate = DateTime.Now, Synchronize = game.sn
                };
                if (gpvm.vedio != null && gpvm.vedio.sn != 0)
                {
                    gp.VedioRecordSn = gpvm.vedio.sn;
                }
                gp.TeamASn    = gpvm.gamepost.TeamASn;
                gp.TeamBSn    = gpvm.gamepost.TeamBSn;
                gp.sdate      = gpvm.game.sdate;
                gp.edate      = gpvm.game.edate;
                gp.PlayGameSn = gpvm.gamepost.PlayGameSn;
                gp.UserLive   = gpvm.game.userId;

                var  cfpgame = new cfgPlayGameRepository().getAllLive();
                bool cf      = false;
                foreach (var cg in cfpgame)
                {
                    if (cg.shortName == gpvm.PlayGame.shortName)
                    {
                        cf            = true;
                        gp.PlayGameSn = cg.sn;
                    }
                }

                if (!cf)
                {
                    cfgPlayGame cfpg = new cfgPlayGame();

                    cfpg.shortName = gpvm.PlayGame.shortName;
                    cfpg.cName     = gpvm.PlayGame.shortName;
                    cfpg.eName     = gpvm.PlayGame.shortName;
                    cfpg.valid     = 2;
                    gp.PlayGameSn  = new cfgPlayGameRepository().Create(cfpg);
                }

                new UserRepository().CreateRecommend(gpvm.game.userId, str(6));

                new GamePostsRepository().add(gp);

                return(gp.sn.ToString());
            }
            catch
            {
                return("0");
            }
        }