コード例 #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            Club2 club2 = db.Clubs.Find(id);

            db.Clubs.Remove(club2);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #2
0
 public ActionResult Edit([Bind(Include = "Id,Name,NickName")] Club2 club2)
 {
     if (ModelState.IsValid)
     {
         db.Entry(club2).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(club2));
 }
コード例 #3
0
        public ActionResult Create([Bind(Include = "Id,Name,NickName")] Club2 club2)
        {
            if (ModelState.IsValid)
            {
                var id = Guid.NewGuid().GetHashCode();

                db.Clubs.Add(club2);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(club2));
        }
コード例 #4
0
        // GET: Club2/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Club2 club2 = db.Clubs.Find(id);

            if (club2 == null)
            {
                return(HttpNotFound());
            }
            return(View(club2));
        }
コード例 #5
0
        // GET: MembershipOption2
        public ActionResult Index(int?clubId, string clubName, string clubNickName)
        {
            if (clubId == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            if (clubName == null)
            {
                Club2DbContext club2Db = new Club2DbContext();
                Club2          club2   = club2Db.Clubs.Find(clubId);

                clubName     = club2.Name;
                clubNickName = club2.NickName;
            }

            ViewBag.ClubId       = clubId;
            ViewBag.ClubName     = clubName;
            ViewBag.ClubNickName = clubNickName;

            return(View(db.MembershipOptions.Where(n => n.ClubId == clubId).ToList()));
        }
コード例 #6
0
        public ActionResult ViewMyMembership(int?userId, int?clubId)
        {
            if (userId == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            if (clubId == null)
            {
                // fetch all memberships
                return(View(db.Memberships.Where(n => n.UserId == userId).ToList()));
            }
            else
            {
                Club2DbContext club2Db = new Club2DbContext();
                Club2          club2   = club2Db.Clubs.Find(clubId);

                ViewBag.ClubName     = club2.Name;
                ViewBag.ClubNickName = club2.NickName;

                // fetch membership of the club Id
                return(View(db.Memberships.Where(n => n.UserId == userId && n.ClubId == clubId).ToList()));
            }
        }