public ActionResult CoachListEdit(Coach coach, string id)
        {
            var result = from item in club.Coachs
                         where item.UserName == id
                         select item;
            Coach personToUpdate = result.FirstOrDefault();

            personToUpdate.Name        = coach.Name;
            personToUpdate.Phone       = coach.Phone;
            personToUpdate.Address     = coach.Address;
            personToUpdate.Age         = coach.Age;
            personToUpdate.Designation = coach.Designation;
            personToUpdate.Email       = coach.Email;
            personToUpdate.Password    = coach.Password;
            club.SaveChanges();
            SignUp sign = new SignUp();
            var    s    = from item in club.SignUps
                          where item.UserName == id
                          select item;

            sign      = s.FirstOrDefault();
            sign.Name = coach.Name;

            sign.Email    = coach.Email;
            sign.Password = coach.Password;
            club.SaveChanges();
            return(RedirectToAction("CoachList", "Coach"));
        }
Ejemplo n.º 2
0
        public ActionResult Create([Bind(Include = "Id,PlayerUserName,MatchId,NumberOfGoals,Point,Card")] Goal goal)
        {
            if (ModelState.IsValid)
            {
                db.Goals.Add(goal);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.MatchId = new SelectList(db.Matches, "Id", "Date", goal.MatchId);

            ViewBag.PlayerUserName = new SelectList(db.Players, "UserName", "Name", goal.Player);
            return(View(goal));
        }
Ejemplo n.º 3
0
        public ActionResult Save()
        {
            var id       = Request["id"].ToInt();
            var name     = Request["name"];
            var account  = Request["account"];
            var levelId  = Request["levelId"].ToInt();
            var integral = Request["integral"].ToInt();
            var image    = Request["image"];


            using (var db = new ClubEntities())
            {
                var user = db.User.FirstOrDefault(a => a.Id == id);

                if (user == null)
                {
                    user          = new User();
                    user.Account  = account;
                    user.IsAdmin  = false;
                    user.PassWord = "******";
                    db.User.Add(user);
                }

                user.Name     = name;
                user.LevelId  = levelId;
                user.integral = integral;
                user.Image    = image;
                db.SaveChanges();

                ShowMsg("操作成功");
            }
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 4
0
        public ActionResult Save()
        {
            var id   = Request["id"].ToInt();
            var name = Request["name"];

            if (string.IsNullOrEmpty(name))
            {
                ShowMsg("分类名称不能为空!");
                return(RedirectToAction("Edit"));
            }

            using (var db = new ClubEntities())
            {
                var category = db.Category.FirstOrDefault(a => a.Id == id);

                if (category == null)
                {
                    category         = new Category();
                    category.IsAbort = false;
                    db.Category.Add(category);
                }

                category.Name = name;
                db.SaveChanges();

                ShowMsg("操作成功");
            }
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 分类管理
        /// </summary>
        /// <returns></returns>


        public ActionResult Delete()
        {
            var idStr = Request["Id"];
            var id    = idStr.ToInt();

            if (id == 0)
            {
                ShowMsg("数据不正确!");

                return(RedirectToAction("Index"));
            }

            using (var db = new ClubEntities())
            {
                var category = db.Category.FirstOrDefault(a => a.Id == id);
                if (category != null)
                {
                    category.IsAbort = true;
                    //db.User.Remove(user);
                    db.SaveChanges();
                }
            }

            ShowMsg("删除成功!");
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 6
0
        public ActionResult Delete()
        {
            var idStr = Request["Id"];
            var id    = idStr.ToInt();

            if (id == 0)
            {
                TempData["Msg"] = "数据不正确!";

                return(RedirectToAction("Index"));
            }

            using (var db = new ClubEntities())
            {
                var user = db.PraiseRecord.FirstOrDefault(a => a.Id == id);
                if (user != null)
                {
                    user.IsAbort = true;
                    //db.User.Remove(user);
                    db.SaveChanges();
                }
            }

            TempData["Msg"] = "删除成功!";

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 7
0
        public ActionResult PlayerListEdit(Player player, string id)
        {
            var result = from item in club.Players
                         where item.UserName == id
                         select item;
            Player personToUpdate = result.FirstOrDefault();

            personToUpdate.Name     = player.Name;
            personToUpdate.Phone    = player.Phone;
            personToUpdate.Address  = player.Address;
            personToUpdate.Age      = player.Age;
            personToUpdate.Position = player.Position;
            personToUpdate.Email    = player.Email;
            personToUpdate.Password = player.Password;

            if (Request.Files.Count > 0)
            {
                var postedFile = Request.Files[0];
                if (postedFile != null && postedFile.ContentLength > 0)
                {
                    string imagesPath  = HttpContext.Server.MapPath("~/Content/Images");
                    string extension   = Path.GetExtension(postedFile.FileName);
                    string newFileName = Session["UserName"] + extension;
                    string saveToPath  = Path.Combine(imagesPath, newFileName);
                    personToUpdate.Image = newFileName;
                    postedFile.SaveAs(saveToPath);
                }
            }



            club.SaveChanges();
            SignUp sign = new SignUp();
            var    s    = from item in club.SignUps
                          where item.UserName == id
                          select item;

            sign          = s.FirstOrDefault();
            sign.Name     = player.Name;
            sign.Email    = player.Email;
            sign.Password = player.Password;



            club.SaveChanges();
            return(RedirectToAction("PlayerList", "Player"));
        }
Ejemplo n.º 8
0
        public ActionResult Create([Bind(Include = "Date,OppositeTeam,Result,Id,Point,Goals")] Match match)
        {
            if (ModelState.IsValid)
            {
                if (match.Result == 1)
                {
                    match.Point = 3;
                }
                else
                {
                    match.Point = 0;
                }
                db.Matches.Add(match);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(match));
        }
        public ActionResult HistoryCreate(History history)
        {
            if (ModelState.IsValid)
            {
                ClubEntities dbObj = new ClubEntities();
                history.Coach = Session["UserName"].ToString();
                dbObj.Histories.Add(history);
                dbObj.SaveChanges();
                return(RedirectToAction("HistoryList"));
            }

            return(View(history));
        }
Ejemplo n.º 10
0
        public ActionResult Create(Notification noti)
        {
            if (ModelState.IsValid)
            {
                db.Notifications.Add(noti);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }


            ViewBag.UserName = new SelectList(db.SignUps, "UserName", "Name", noti.UserName);
            return(View(noti));
        }
Ejemplo n.º 11
0
        public ActionResult Save()
        {
            var id           = Request["id"].ToInt();
            int isfeaturedid = Request["isfeaturedid"].ToInt();
            int categoryId   = Request["categoryId"].ToInt();

            using (var club = new ClubEntities())
            {
                var post = club.Post.FirstOrDefault(a => a.Id == id);
                post.CategoryId = categoryId;
                post.IsFeatured = isfeaturedid.ToBit();
                club.SaveChanges();
            }
            ShowMsg("操作成功");
            return(RedirectToAction("Index"));
        }
        public ActionResult Signup(SignUp sign)
        {
            if (ModelState.IsValid)
            {
                //Signup s = new Signup();
                club.SignUps.Add(sign);

                try
                {
                    club.SaveChanges();
                }

                catch (DbUpdateException e)
                {
                    ModelState.AddModelError("UserName", "Username allready existed");

                    return(View(sign));
                }



                var test = club.SignUps.Where(x => x.Type == sign.Type).FirstOrDefault();
                if (test.Type == "Player")
                {
                    Player p = new Player();
                    p.UserName = sign.UserName;
                    p.Password = sign.Password;
                    p.Salary   = sign.Salary;
                    p.Email    = sign.Email;
                    p.Name     = sign.Name;

                    club.Players.Add(p);
                    club.SaveChanges();
                    return(RedirectToAction("PlayerList"));
                }
                else
                {
                    Coach c = new Coach();
                    c.UserName = sign.UserName;
                    c.Password = sign.Password;
                    c.Salary   = sign.Salary;
                    c.Email    = sign.Email;
                    c.Name     = sign.Name;

                    club.Coachs.Add(c);
                    club.SaveChanges();
                    return(RedirectToAction("CoachList"));
                }
            }

            return(View(sign));
        }
Ejemplo n.º 13
0
        public ActionResult Edit(SignUp sign, string id)
        {
            var result = from item in club.SignUps
                         where item.UserName == id
                         select item;
            SignUp personToUpdate = result.FirstOrDefault();

            personToUpdate.Name     = sign.Name;
            personToUpdate.Salary   = sign.Salary;
            personToUpdate.Email    = sign.Email;
            personToUpdate.Password = sign.Password;
            personToUpdate.Type     = sign.Type;

            club.SaveChanges();
            var test = club.SignUps.Where(x => x.Type == sign.Type).FirstOrDefault();

            if (test.Type == "Player")
            {
                var p = from item in club.Players
                        where item.UserName == id
                        select item;
                Player player = new Player();
                player          = p.FirstOrDefault();
                player.Name     = sign.Name;
                player.Password = sign.Password;
                player.Email    = sign.Email;
                player.Salary   = sign.Salary;


                club.SaveChanges();
            }
            else if (test.Type == "Coach")
            {
                var c = from item in club.Coachs
                        where item.UserName == id
                        select item;
                Coach coach = new Coach();
                coach          = c.FirstOrDefault();
                coach.Name     = sign.Name;
                coach.Password = sign.Password;
                coach.Email    = sign.Email;
                coach.Salary   = sign.Salary;
                club.SaveChanges();
            }


            return(RedirectToAction("UserList", "Admin"));
        }
Ejemplo n.º 14
0
        public ActionResult Save()
        {
            var categoryId = Request["categoryId"].ToInt();
            var title      = Request["title"];
            var content    = Request["content"];
            var loginUser  = (User)Session["loginUser"];

            if (categoryId == 0)
            {
                ShowMsg("帖子分类不能为空");
                return(RedirectToAction("New"));
            }

            if (string.IsNullOrEmpty(title))
            {
                ShowMsg("帖子标题不能为空");
                return(RedirectToAction("New"));
            }
            if (string.IsNullOrEmpty(content))
            {
                ShowMsg("帖子内容不能为空");
                return(RedirectToAction("New"));
            }

            using (var db = new ClubEntities())
            {
                var post = new Post();
                post.CategoryId = categoryId;
                post.Title      = title;
                post.Details    = content;
                post.CreateTime = DateTime.Now;
                post.UserId     = loginUser.Id;
                post.IsFeatured = true;
                db.Post.Add(post);
                db.SaveChanges();
                ShowMsg("发布成功");
                return(Redirect("/"));
            }
        }
        public ActionResult SelectPlayerForTeam(TeamsPlayer item)
        {
            ViewBag.Allplayer = getAllPlayers();
            /*ViewBag.GetPlayer = GetPlayer();*/
            ViewBag.GetMatch = GetMatch();

            if (team.TeamForMatches.Where(x => x.MatchID == item.MatchID).Count() >= 14)
            {
                ViewBag.Error = "Already 14 players existed!!";
                return(View());
            }

            DateTime date = team.Matches.Find(item.MatchID).Date ?? DateTime.Now;

/*            if (item.Match != null)
 *          {
 *              date = item.Match.Date ;
 *          }*/

            foreach (var data in item.PlayerUserName)
            {
                TeamForMatch tdm = new TeamForMatch();
                tdm.MatchID  = item.MatchID;
                tdm.Note     = item.Note;
                tdm.status   = item.status;
                tdm.Team     = item.Team;
                tdm.Username = data;
                team.TeamForMatches.Add(tdm);

                team.Notifications.Add(new Notification {
                    UserName = data, Title = "You are selected.", Description = "You are selected for " + date.ToString("dd/MM/yy") + " .Please check Proposed_Selectted_Player to Details.", Date = DateTime.Now
                });
                team.SaveChanges();
            }



            return(RedirectToAction("Coach", "Coach"));
        }
Ejemplo n.º 16
0
        public ActionResult Register(UserRegisterParams userRegisterParams)
        {
            using (var db = new ClubEntities())
            {
                var user = db.User.FirstOrDefault(a => a.Account == userRegisterParams.Account);
                if (user != null)
                {
                    ShowMsg("该用户已存在");
                    return(View());
                }

                user            = new User();
                user.Account    = userRegisterParams.Account;
                user.PassWord   = userRegisterParams.PassWord.MD5Encoding(user.Account);
                user.Name       = userRegisterParams.Name;
                user.CreateTime = DateTime.Now;
                user.LevelId    = 1;
                db.User.Add(user);
                db.SaveChanges();
                ShowMsg("用户注册成功,请登录");
            }
            return(View());
        }
Ejemplo n.º 17
0
        public ActionResult Save()
        {
            var id   = Request["id"].ToInt();
            var name = Request["name"];

            using (var db = new ClubEntities())
            {
                var level = db.Level.FirstOrDefault(a => a.Id == id);

                if (level == null)
                {
                    level         = new Level();
                    level.IsAbort = false;
                    db.Level.Add(level);
                }

                level.Name = name;
                db.SaveChanges();

                ShowMsg("操作成功");
            }
            return(RedirectToAction("Index"));
        }