public ActionResult Edit(int id)
        {
            Together together = TogetherRepository.GetTogether(id);

            if (!together.IsHostedBy(User.Identity.Name))
            {
                return(View("InvalidOwner"));
            }

            return(View(new TogetherFormViewModel(together)));
        }
Ejemplo n.º 2
0
        public ContentResult Register(int id)
        {
            Together together = TogetherRepository.GetTogether(id);

            if (!together.IsUserRegistered(User.Identity.Name))
            {
                Attendee attendee = new Attendee();
                attendee.AttendeeBy = User.Identity.Name;
                attendee.UserName   = User.Identity.UserName();
                attendee.TinyURL    = User.Identity.TinyURL();
                together.Attendees.Add(attendee);
                TogetherRepository.Save();
            }
            return(Content("лл£¬²»¼û²»É¢Å¶£¡"));
        }
        public ActionResult Delete(int id, string confirmButton)
        {
            Together together = TogetherRepository.GetTogether(id);

            if (!together.IsHostedBy(User.Identity.Name))
            {
                return(View("InvalidOwner"));
            }

            if (together == null)
            {
                return(View("NotFound"));
            }
            TogetherRepository.Delete(together);
            TogetherRepository.Save();
            return(View("Deleted"));
        }
        public ActionResult Delete(int id)
        {
            Together together = TogetherRepository.GetTogether(id);

            if (!together.IsHostedBy(User.Identity.Name))
            {
                return(View("InvalidOwner"));
            }

            if (together == null)
            {
                return(View("NotFound"));
            }
            else
            {
                return(View(together));
            }
        }
        public ActionResult Edit(int id, FormCollection formValues)
        {
            Together together = TogetherRepository.GetTogether(id);

            if (!together.IsHostedBy(User.Identity.Name))
            {
                return(View("InvalidOwner"));
            }

            try
            {
                UpdateModel(together);

                TogetherRepository.Save();

                return(RedirectToAction("Details", new { id = together.TogetherID }));
            }
            catch
            {
                ModelState.AddRuleViolations(together.GetRuleViolations());
                return(View(new TogetherFormViewModel(together)));
            }
        }
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction("Index"));
            }

            Together together = TogetherRepository.GetTogether(id.Value);

            // 留言Form用的
            Post postForm = new Post();

            postForm.TogetherID  = together.TogetherID;
            ViewData["PostForm"] = postForm;

            if (together == null)
            {
                return(View("NotFound"));
            }
            else
            {
                return(View(together));
            }
        }