Ejemplo n.º 1
0
        public ActionResult Edit(int? id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            Voting voting = db.Votings.Find(id);
            if (voting == null)
            {
                return HttpNotFound();
            }

            var view = new VotingView
            {
              DateEnd = voting.DateTimeEnd,
              DateStart = voting.DateTimeStart,
              Description = voting.Description,
              IsEnabledBlankVote = voting.IsEnabledBlankVote,
              IsForAllUsers = voting.IsForAllUsers,
              Remarks = voting.Remarks,
              StateId = voting.StateId,
              TimeEnd = voting.DateTimeEnd,
              TimeStart = voting.DateTimeStart,
              VotingId = voting.VotingId,
            };

            ViewBag.StateId = new SelectList(db.States, "StateId", "Description", voting.StateId);
            return View(view);
        }
Ejemplo n.º 2
0
        public ActionResult Edit(VotingView view)
        {
            if (ModelState.IsValid)
            {

                //crear objeto voting con relacaión a VotingView:
                var voting = new Voting
                {
                    VotingId = view.VotingId,
                    DateTimeStart = view.TimeStart.AddHours(view.TimeStart.Hour).AddMinutes(view.TimeStart.Minute),
                    DateTimeEnd = view.TimeEnd.AddHours(view.TimeEnd.Hour).AddMinutes(view.TimeEnd.Minute),
                    Description = view.Description,
                    IsEnabledBlankVote = view.IsEnabledBlankVote,
                    IsForAllUsers = view.IsForAllUsers,
                    Remarks = view.Remarks,
                    StateId = view.StateId,


                };

                db.Entry(voting).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            ViewBag.StateId = new SelectList(db.States, "StateId", "Description", view.StateId);
            return View(view);
        }
Ejemplo n.º 3
0
        // GET: Votings/Create
        public ActionResult Create()
        {
            ViewBag.StateId = new SelectList(db.States, "StateId", "Description");

            var view = new VotingView
            {
                DateStart = DateTime.Now,
                DateEnd = DateTime.Now,
                
            };

            return View(view);
        }