Пример #1
0
 public ActionResult Create([Bind(Include = "UserID,FirstName,LastName,Username,Password,ConfirmPassword,Email,Phone,Job,Gender")] User user)
 {
     if (ModelState.IsValid)
     {
         db.Users.Add(user);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(user));
 }
Пример #2
0
 public ActionResult Create([Bind(Include = "MemberID,FirstName,LastName,Username,Password,ConfirmPassword,Email")] Member member)
 {
     if (ModelState.IsValid)
     {
         db.Members.Add(member);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(member));
 }
 public ActionResult Create([Bind(Include = "ServiceID,StartDate,FinishDate,StartLocation,FinishLocation,Capacity,Price")] Service service)
 {
     if (ModelState.IsValid)
     {
         db.Services.Add(service);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(service));
 }
        public ActionResult Create([Bind(Include = "CategoryID,CategoryName")] Category category)
        {
            if (ModelState.IsValid)
            {
                db.Categories.Add(category);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(category));
        }
Пример #5
0
        public ActionResult Create([Bind(Include = "PlayerID,PlayerName")] Player player)
        {
            if (ModelState.IsValid)
            {
                db.Players.Add(player);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }


            return(View(player));
        }
Пример #6
0
        public ActionResult Create([Bind(Include = "TeamsID,TeamName,Score,players")] Team team)
        {
            var players = db.Players.Select(x => x.PlayerName).OrderBy(y => Guid.NewGuid()).ToList();

            var j = 1;

            for (int i = 0; i < players.Count; i += 2, j++)
            {
                db.Teams.Add(new Team {
                    TeamName = "Team " + j, players = players[i] + ", " + players[i + 1], Score = 0,
                });
            }
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #7
0
        public ActionResult Create([Bind(Include = "WordsID,Word1,PlayerID")] Word word)
        {
            var wordModel = new WordsModel();

            db.Words.Add(word);
            db.SaveChanges();
            if (db.Words.Select(x => x.WordsID).Count() % 5 == 0)
            {
                return(RedirectToAction("Index"));
            }


            ViewBag.PlayerID = new SelectList(db.Players, "PlayerID", "PlayerName", word.PlayerID);

            ModelState.Clear();
            return(RedirectToAction("Create"));
        }
Пример #8
0
        // GET: StartGame/StartGame/5
        public ActionResult StartGame()

        {
            var idList = db.Words.Select(x => x.WordsID).OrderBy(y => Guid.NewGuid()).ToList();

            if (idList.Count == 0)
            {
                return(RedirectToAction("Finish"));
            }
            Word word = db.Words.Find(idList[0]);



            db.Words.Remove(word);
            db.SaveChanges();



            return(View(word));
        }