public ActionResult Create([Bind(Include = "ID,Name,LogoPath,SelectedTeams,FoudationDate,CountryID,EntityMngID")] Championship championship)
        {
            if (championship.LogoPath != null && championship.LogoPath.ContentLength > 0)
            {
                string filename = DateTime.Now.Ticks + Path.GetExtension(championship.LogoPath.FileName);

                var imagePath = Path.Combine(Server.MapPath(Utils.UPLOAD), filename);
                var imageUrl  = Path.Combine(Utils.UPLOAD, filename);
                championship.LogoPath.SaveAs(imagePath);

                championship.Logo = String.Concat(Utils.UPLOAD, "/", filename);
            }

            if (ModelState.IsValid)
            {
                try {
                    db.Championship.Add(championship);
                    db.SaveChanges();

                    Season season = new Season();
                    season.ChampshipID   = championship.ID;
                    season.NumberOfTeams = 0;
                    season.Year          = DateTime.Now;

                    db.Season.Add(season);
                    db.SaveChanges();

                    foreach (var team in championship.SelectedTeams.Split(','))
                    {
                        TeamPoints teamPts = new TeamPoints();
                        teamPts.ChampshipID = championship.ID;
                        teamPts.Points      = 0;
                        teamPts.TeamID      = int.Parse(team);

                        db.TeamPoints.Add(teamPts);
                        db.SaveChanges();
                    }

                    return(RedirectToAction("Create", "Journeys", new { area = "", id = championship.ID }));
                } catch (DbEntityValidationException dbEx) {
                    foreach (var validationErrors in dbEx.EntityValidationErrors)
                    {
                        foreach (var validationError in validationErrors.ValidationErrors)
                        {
                            System.Diagnostics.Trace.TraceInformation("\n\rProperty: {0}\n\r Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
                            return(RedirectToAction("Create"));
                        }
                    }
                }
            }

            ViewBag.EntityMngID = new SelectList(db.EntityManager, "ID", "Name", championship.EntityMngID);
            ViewBag.CountryID   = new SelectList(db.Country, "ID", "Name", championship.CountryID);
            return(View(championship));
        }
        public ActionResult Create([Bind(Include = "ID,Name,UserID")] EntityManager entityManager)
        {
            if (ModelState.IsValid)
            {
                db.EntityManager.Add(entityManager);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(entityManager));
        }
        public ActionResult Create([Bind(Include = "ID,Name")] Country country)
        {
            if (ModelState.IsValid)
            {
                db.Country.Add(country);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(country));
        }
        public ActionResult Create([Bind(Include = "ID,ChampshipID,Year,NumberOfTeams")] Season season)
        {
            if (ModelState.IsValid)
            {
                db.Season.Add(season);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ChampshipID = new SelectList(db.Championship, "ID", "Name", season.ChampshipID);
            return(View(season));
        }
        public ActionResult Create([Bind(Include = "ID,Name,Birth,CountryID,TeamID")] Player player)
        {
            if (ModelState.IsValid)
            {
                db.Player.Add(player);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CountryID = new SelectList(db.Country, "ID", "Name", player.CountryID);
            ViewBag.TeamID    = new SelectList(db.Team, "ID", "Name", player.TeamID);
            return(View(player));
        }
        public ActionResult Create([Bind(Include = "TeamID,ChampshipID,Points")] TeamPoints teamPoints)
        {
            if (ModelState.IsValid)
            {
                db.TeamPoints.Add(teamPoints);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ChampshipID = new SelectList(db.Championship, "ID", "Name", teamPoints.ChampshipID);
            ViewBag.TeamID      = new SelectList(db.Team, "ID", "Name", teamPoints.TeamID);
            return(View(teamPoints));
        }
        public ActionResult Create([Bind(Include = "ID,ChampshipID,DateBegin,DateEnd")] Journey journey, string champID)
        {
            System.Diagnostics.Trace.WriteLine(champID);
            journey.ChampshipID = int.Parse(champID);
            if (ModelState.IsValid)
            {
                db.Journey.Add(journey);
                db.SaveChanges();
                return(RedirectToAction("Create", "Matches", new { area = "", id = journey.ID }));
            }

            ViewBag.ChampshipID = new SelectList(db.Championship, "ID", "Name", journey.ChampshipID);
            return(View(journey));
        }
        public ActionResult Create([Bind(Include = "ID,JourneyID,Date,KickoffTime,VisitorTeamID,GuestTeamID")] Match match, string journeyID)
        {
            System.Diagnostics.Trace.WriteLine(journeyID);
            match.JourneyID = int.Parse(journeyID);
            if (ModelState.IsValid)
            {
                db.Match.Add(match);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.GuestTeamID   = new SelectList(db.Team, "ID", "Name", match.GuestTeamID);
            ViewBag.VisitorTeamID = new SelectList(db.Team, "ID", "Name", match.VisitorTeamID);
            return(View(match));
        }
        public ActionResult Create([Bind(Include = "ID,MatchID,goalTime,TeamID,PlayerID,Time")] MatchGoals matchGoals)
        {
            //atribui o tempo a que o golo foi marcado e converte para string
            string time = matchGoals.goalTime;

            //divide o tempo numa array em que o primeiro valor corresponde a MM(M) e o segundo a SS
            //converte os valores para int
            int[] timeArr = Array.ConvertAll(time.Split(':'), int.Parse);
            //int[] timeArr = time.Split(':').Select(n => Convert.ToInt32(n)).ToArray();

            //converte MM(M) para H:MM
            int totalMinutes = timeArr[0];
            int hours        = totalMinutes / 60;
            int min          = totalMinutes % 60;
            int sec          = timeArr[1];

            //obtem a data atual
            DateTime currDate = DateTime.Now;
            //cria uma nova variavel de data, definindo a data para a atual, e a hora para as referentes ao golo
            DateTime date = new DateTime(currDate.Year, currDate.Month, currDate.Day, hours, min, sec);

            //atribui o tempo a que o golo foi marcado convertido de MM(M):SS para HH:MM:SS
            matchGoals.Time     = date;
            matchGoals.PlayerID = 2;

            if (ModelState.IsValid)
            {
                try{
                    db.MatchGoals.Add(matchGoals);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                } catch (DbEntityValidationException dbEx) {
                    foreach (var validationErrors in dbEx.EntityValidationErrors)
                    {
                        foreach (var validationError in validationErrors.ValidationErrors)
                        {
                            System.Diagnostics.Trace.TraceInformation("\n\rProperty: {0}\n\r Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
                            return(RedirectToAction("Create"));
                        }
                    }
                }
            }

            ViewBag.MatchID  = new SelectList(db.Match, "ID", "ID", matchGoals.MatchID);
            ViewBag.PlayerID = new SelectList(db.Player, "ID", "Name", matchGoals.PlayerID);
            ViewBag.TeamID   = new SelectList(db.Team, "ID", "Name", matchGoals.TeamID);
            return(View(matchGoals));
        }
Example #10
0
        public bool LoginCommand(IConnection conn, UserDto dto)
        {
            UserDto _dto; //更新在线用户列表   //没有判断同一个账号在不同客户端同时登录的情况

            if (CurrentClient.TryGetValue(conn.ConnectionID, out _dto))
            {
                dto.ConnectionID = conn.ConnectionID;
                dto.BeatTime     = DateTime.Now;
                dto.IpAddress    = conn.RemoteEndPoint.ToString();
                dto.ConnectTime  = _dto.ConnectTime;
                dto.IsLogin      = true;
                CurrentClient.TryUpdate(conn.ConnectionID, dto, _dto);
                //return true;
            }
            try
            {
                AppLog.WriteLog(dto.DeptName + dto.StaffName + "使用" + dto.UserName + "登录系统");
                using (FMDBEntities db = new FMDBEntities())
                {
                    var OnlineLoginID = CurrentClient.Values.Select(i => i.LoginID).ToList();

                    var loginedmodel = db.System_Login.Where(i => OnlineLoginID.Contains(i.LoginID)).ToList();
                    foreach (var model in loginedmodel)
                    {
                        if (model != null)
                        {
                            if (model.IsOnline == null || model.IsOnline == false) //更新数据库中已登录的账户的状态
                            {
                                model.IsOnline = true;
                            }
                            model.IP = CurrentClient.Values.First(t => t.LoginID == model.LoginID).IpAddress;
                        }
                    }
                    var OffLine = db.System_Login.Where(i => i.StatusValue == 1 && !OnlineLoginID.Contains(i.LoginID)).ToList();
                    foreach (var offlinesuer in OffLine)
                    {
                        if (offlinesuer != null)
                        {
                            if (offlinesuer.IsOnline == true || offlinesuer.IsOnline == null)//更新数据库中未登录的账户的状态,防止server崩溃后,用户也下线了,当再次启动服务的时候该用户的在线的状态一直不会被改变一直处于在线状态
                            {
                                offlinesuer.IsOnline = false;
                            }
                        }
                    }
                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                //DisplayMsg(ex.StackTrace);
                AppLog.WriteLog("用户登录后修改数据库值出错" + ex.StackTrace);
                //throw;
            }
            return(true);//todo:需要登陆验证
        }
        public ActionResult Create([Bind(Include = "ID,Name,LogoPath,FundationDate,CountryID,City")] Team team)
        {
            if (team.LogoPath != null && team.LogoPath.ContentLength > 0)
            {
                string filename = DateTime.Now.Ticks + Path.GetExtension(team.LogoPath.FileName);

                var imagePath = Path.Combine(Server.MapPath(Utils.UPLOAD), filename);
                var imageUrl  = Path.Combine(Utils.UPLOAD, filename);
                team.LogoPath.SaveAs(imagePath);

                team.Logo = String.Concat(Utils.UPLOAD, "/", filename);
            }
            if (ModelState.IsValid)
            {
                db.Team.Add(team);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CountryID = new SelectList(db.Country, "ID", "Name", team.CountryID);
            return(View(team));
        }
Example #12
0
        public void DisconnectionCommand(IConnection conn)
        {
            UserDto _dto;

            CurrentClient.TryRemove(conn.ConnectionID, out _dto);
            DisplayMsg(string.Format(" 用户 {0} ({1}) 断开链接了 ", _dto.UserName, _dto.StaffName));
            using (FMDBEntities db = new FMDBEntities())
            {
                var model = db.System_Login.FirstOrDefault(i => i.LoginID == _dto.LoginID);
                if (model != null)
                {
                    model.IsOnline = false;
                }
                db.SaveChanges();
            }
        }