public ActionResult Create(Together together) { if (ModelState.IsValid) { try { together.HostedBy = User.Identity.Name; together.TinyURL = User.Identity.TinyURL(); together.UserName = User.Identity.UserName(); Attendee attendee = new Attendee(); attendee.AttendeeBy = User.Identity.Name; attendee.UserName = User.Identity.UserName(); attendee.TinyURL = User.Identity.TinyURL(); together.Attendees.Add(attendee); TogetherRepository.Add(together); TogetherRepository.Save(); return(RedirectToAction("Details", new { id = together.TogetherID })); } catch { ModelState.AddRuleViolations(together.GetRuleViolations()); return(View(new TogetherFormViewModel(together))); } } return(View(new TogetherFormViewModel(together))); }
public ActionResult Edit(int id) { Together together = TogetherRepository.GetTogether(id); if (!together.IsHostedBy(User.Identity.Name)) { return(View("InvalidOwner")); } return(View(new TogetherFormViewModel(together))); }
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 JsonResult SearchByLocation(float longitude, float latitude, TogetherTypeWithAllEnum?togetherType) { var togethers = TogetherRepository.FindByLocation(latitude, longitude, togetherType ?? TogetherTypeWithAllEnum.All); var jsonTogethers = from together in togethers select new JsonTogether { TogetherID = together.TogetherID, Title = together.Title, TogetherType = together.TogetherTypeString, Description = together.Description, HostBy = together.HostedBy, UserName = together.UserName, StartDate = together.StartDate.ToString(), Address = together.Address, PicURL = together.PicURL, Latitude = together.Latitude, Longitude = together.Longitude, AttendeeCount = together.Attendees.Count }; return(Json(jsonTogethers.ToList())); }
public ActionResult Details(Post post) { if (ModelState.IsValid) { try { post.PostDate = DateTime.Now; post.PostBy = User.Identity.Name; post.UserName = User.Identity.UserName(); post.TinyURL = User.Identity.TinyURL(); TogetherRepository.AddPost(post); TogetherRepository.Save(); return(RedirectToAction("Details", new { id = post.TogetherID })); } catch { ModelState.AddRuleViolations(post.GetRuleViolations()); } } ViewData["PostForm"] = post; return(View(post.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)); } }
public ActionResult Index(int?page) { var togethers = TogetherRepository.FindUpcomingTogethers(page); return(View(togethers)); }