Exemplo n.º 1
0
        // GET: Membership/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Membership membership = db.Memberships.Find(id);

            if (membership == null)
            {
                return(HttpNotFound());
            }
            membership.CalculateMembershipPrice();
            ViewBag.CustomerID = new SelectList(db.Customers, "ID", "Name", membership.CustomerID);
            return(View(membership));
        }
Exemplo n.º 2
0
        public ActionResult Create([Bind(Include = "MembershipID,CustomerID,MembershipLevel,EffectiveDate,ExpirationDate,Price")] Membership membership)
        {
            try
            {
                membership.CalculateMembershipPrice();
                if (ModelState.IsValid)
                {
                    db.Memberships.Add(membership);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }

                ViewBag.CustomerID = new SelectList(db.Customers, "ID", "Name", membership.CustomerID);
            }
            catch (RetryLimitExceededException)
            {
                ModelState.AddModelError("", "Unable to Save Changes.");
            }

            return(View(membership));
        }