コード例 #1
0
ファイル: AdminController.cs プロジェクト: as92/Rezultati
        public ActionResult DodajUtakmicu(Utakmice game)
        {
            if (ModelState.IsValid)
            {
                using (UsersEntities1 ue = new UsersEntities1())

                {
                    game.golDomacin = 0;
                    game.golGost    = 0;
                    game.rezultat   = " - ";

                    int result = DateTime.Compare(game.PocetakUtakmice, DateTime.Now);
                    if (result < 0)
                    {
                        ViewBag.UsporediMessage     = game.PocetakUtakmice.ToString() + " je prije " + DateTime.Now.ToString();
                        ViewBag.UnsuccessfulMessage = "Utakmica nije dodana";
                        return(PartialView());
                    }
                    else if (result == 0)
                    {
                        ViewBag.UsporediMessage     = game.PocetakUtakmice.ToString() + " je u isto vrijeme kao " + DateTime.Now.ToString();
                        ViewBag.UnsuccessfulMessage = "Utakmica nije dodana";
                        return(PartialView());
                    }
                    else
                    {
                        ViewBag.UsporediMessage = game.PocetakUtakmice.ToString() + " je poslije " + DateTime.Now.ToString();
                        ue.Utakmice.Add(game);
                        ue.SaveChanges();
                        ModelState.Clear();
                        ViewBag.SuccessMessage = "Utakmica dodana";
                        ViewBag.Users          = users.Users.ToList();
                        return(RedirectToAction("DodajUtakmicu", "Admin"));
                        //return PartialView();
                    }
                }
            }
            else
            {
                return(PartialView());
            }
        }