public ActionResult MyEvents(Guid?id, int?page, string search, string currentfilter) { var currentuser = HttpContext.User.Identity.Name; var currentuserId = idb.Users.Where(a => a.UserName == currentuser).Select(a => a.Id).First(); if (search != null) { page = 1; } else { search = currentfilter; } ViewBag.CurrentFilter = search; int pageSize = 5; int pageNumber = (page ?? 1); if (!String.IsNullOrEmpty(search)) { if (User.IsInRole("Administrator")) { var events = ManageEvents.GetEvents().Where(a => a.event_name.IndexOf(search, StringComparison.OrdinalIgnoreCase) != -1); return(View(events.OrderByDescending(a => a.date_created).ToPagedList(pageNumber, pageSize))); } else { //var events = ManageEvents.GetEvents().Where(a => a.event_name.Contains(search)); //return View(events.OrderByDescending(a => a.date_created).ToPagedList(pageNumber, pageSize)); var events = ManageEvents.GetEvents().Where(a => a.event_name.IndexOf(search, StringComparison.OrdinalIgnoreCase) != -1); return(View(events.OrderByDescending(a => a.date_created).ToPagedList(pageNumber, pageSize))); } } else { if (User.IsInRole("Administrator")) { var events = ManageEvents.GetEvents(); ViewBag.EventsCount = ManageParticipants.CountParticipants(id); return(View(events.OrderByDescending(a => a.date_created).ToPagedList(pageNumber, pageSize))); } else { var events = ManageEvents.GetMyEvents(currentuserId); ViewBag.EventsCount = ManageParticipants.CountParticipants(id); return(View(events.OrderByDescending(a => a.date_created).ToPagedList(pageNumber, pageSize))); } } }
public ActionResult Index() { var currentuser = HttpContext.User.Identity.Name; var userid = ManageEvents.CreatedByLoginID(currentuser); var count = ManageEvents.GetMyEvents(userid).Count(); if (count != 0) { return(RedirectToAction("MyEvents", "Events")); } else { return(View()); } }