Exemplo n.º 1
0
        public ActionResult Create(NewProvisionView provision)
        {
            if (ModelState.IsValid)
            {
                int bill = int.Parse(TempData["Bill"].ToString());
                LegislationManager billManager = new LegislationManager();
                billManager.Include(provision, bill);
                return RedirectToAction("Index", "Home");
            }

            return View(provision);
        }
Exemplo n.º 2
0
        public int Include(NewProvisionView article, int bill)
        {
            var legislation = db.Legislations.Find(bill);

            if (legislation != null)
            {
                try
                {
                    var provision = new Provision
                    {
                        Article = Numbers.CountOrNull(legislation.Provisions) + 1,
                        Text = article.Text,
                        Enactment = new Enactment
                        {
                            EnactmentType = 1,
                            EnactingOrder = null,
                            EnactingDate = DateTime.Parse(article.EnactingDate)
                        },
                        Proponent = db.Members.SingleOrDefault(m => m.Username == HttpContext.Current.User.Identity.Name)
                    };

                    legislation.Provisions.Add(provision);
                    db.SaveChanges();

                    return provision.ProvisionID;
                }
                catch (Exception)
                {
                    return 0;
                }
            }
            else
            {
                return 0;
            }
        }