Exemplo n.º 1
0
        public ActionResult CreateBet(MyBetModel newBet)
        {
            try
            {
                // TODO: Add insert logic here

                BetsDBDataContext context = new BetsDBDataContext();

                Bet bet = new Bet();
                bet.name = newBet.Name;
                bet.description = newBet.Description;
                context.Bets.InsertOnSubmit(bet);
                context.SubmitChanges();

                if (Request.Files.Count > 0)
                {
                    List<HttpPostedFileBase> files = TempData["appl"] as List<HttpPostedFileBase>;

                    if (files != null && files.Count != 0)
                    {
                        MyBetModel.WriteFileInDB(files, bet.id);
                        TempData.Clear();
                    }
                }

                return RedirectToAction("CreateOutcome", "Outcome", new { idBet = bet.id });
            }
            catch
            {
                return View();
            }
        }
Exemplo n.º 2
0
        public ActionResult Edit(MyBetModel betM)
        {
            try
            {
                BetsDBDataContext context = new BetsDBDataContext();

                Bet bet = context.Bets.Where(b => b.id == betM.id).First();
                if(bet!=null)
                {
                    bet.name = betM.Name;
                    bet.description = betM.Description;
                    context.SubmitChanges();

                    return RedirectToAction("Index", new { id = bet.id });
                }

                return RedirectToAction("Index","Home");
            }
            catch
            {
                return View();
            }
        }
Exemplo n.º 3
0
        //
        // GET: /Bet/
        public ActionResult Index(int id)
        {
            Bet bet = context.Bets.Where(b => b.id == id).First();

            if(bet==null)
            {
                return HttpNotFound();
            }

            MyBetModel betM = new MyBetModel();
            betM.id = bet.id;
            betM.Name = bet.name;
            betM.Description = bet.description;

            var lstOutcomes = context.BindBetOutcomes.Where(b => b.idBet == bet.id).Select(b=>b.idOutcome).ToList();

            var lstInfOutcomes = context.Outcomes.Where(o => lstOutcomes.Contains(o.id)).Select(o => o.id + "|" + o.name).ToList();
            ViewBag.lstInfOutcomes = lstInfOutcomes;

            return View(betM);
        }
Exemplo n.º 4
0
        //
        // GET: /Bet/Edit/5
        public ActionResult Edit(int id)
        {
            Bet bet = context.Bets.Where(b => b.id == id).First();

            if (bet == null)
            {
                return HttpNotFound();
            }

            MyBetModel betM = new MyBetModel();
            betM.id = bet.id;
            betM.Name = bet.name;
            betM.Description = bet.description;

            return View(betM);
        }