public ViewResult GetGuests(string category = null, int page = 1) { GuestListViewModel model = new GuestListViewModel() { GuestResponses = repository.GuestResponses .Where(g => category == null || g.WillAttend.ToString() == category) .OrderBy(g => g.Name) .Skip((page - 1) * pageSize) .Take(pageSize), PagingInfo = new PagingInfo { CurrentPage = page, ItemsPerPage = pageSize, TotalItems = category == null? repository.GuestResponses.Count() : repository.GuestResponses.Count(g => g.WillAttend.ToString() == category) }, CurrentCategory = category }; if (model.GuestResponses.Any()) { return(View("FilledGuestList", model)); } else { return(View("EmptyGuestList")); } }
public ActionResult Index() { GuestListViewModel guestListViewModel = new GuestListViewModel(); GuestBusinessLayer guestBusinessLayer = new GuestBusinessLayer(); List <Guest> guests = guestBusinessLayer.GetGuests(); List <GuestViewModel> mylist = new List <GuestViewModel>(); int count = 0; foreach (Guest gs in guests) { if (count == 10) { break; } GuestViewModel guestViewModel = new GuestViewModel(); guestViewModel.Name = gs.Name; guestViewModel.GuestId = gs.GuestId.ToString(); guestViewModel.ContactNo = gs.ContactNo; guestViewModel.TableNo = gs.TableNo; guestViewModel.Attendance = gs.Attendance; mylist.Add(guestViewModel); count++; } guestListViewModel.Guest = mylist; return(View("Index", guestListViewModel)); }
public ActionResult FindGuest() { string searchname = Request.Form["SearchByName"]; GuestListViewModel guestListViewModel = new GuestListViewModel(); GuestBusinessLayer guestBusinessLayer = new GuestBusinessLayer(); List <Guest> guests = new List <Guest>(); if (searchname == "all") { guests = guestBusinessLayer.GetGuests(); } else if (searchname != null && searchname != "") { guests = guestBusinessLayer.FindGuests(searchname); } List <GuestViewModel> mylist = new List <GuestViewModel>(); foreach (Guest gs in guests) { GuestViewModel guestViewModel = new GuestViewModel(); guestViewModel.Name = gs.Name; guestViewModel.GuestId = gs.GuestId.ToString(); guestViewModel.ContactNo = gs.ContactNo; guestViewModel.TableNo = gs.TableNo; guestViewModel.Attendance = gs.Attendance; mylist.Add(guestViewModel); } guestListViewModel.Guest = mylist; return(View("Index", guestListViewModel)); }
public async Task <IActionResult> AllGuests() { var user = await this.userManager.GetUserAsync(this.User); var viewModel = new GuestListViewModel() { BrideGuests = this.guestsService.GetAll(user.Id, 1), GroomGuests = this.guestsService.GetAll(user.Id, 2), }; return(this.View(viewModel)); }
public JsonResult JUpdateAttd(AttdViewModel g) { string GuestId = g.GuestId; bool Attendance = g.Attendance; int GuestIdInt = int.Parse(g.GuestId); GuestListViewModel guestListViewModel = new GuestListViewModel(); GuestBusinessLayer guestBusinessLayer = new GuestBusinessLayer(); if (Attendance) { guestBusinessLayer.SetAttd(GuestId); } else { guestBusinessLayer.DelAttd(GuestId); } return(Json(g, JsonRequestBehavior.AllowGet)); }
public ActionResult ManageGuests() { GuestListViewModel guestListViewModel = new GuestListViewModel(); GuestBusinessLayer guestBusinessLayer = new GuestBusinessLayer(); List <Guest> guests = guestBusinessLayer.GetGuests(); List <GuestViewModel> mylist = new List <GuestViewModel>(); foreach (Guest gs in guests) { GuestViewModel guestViewModel = new GuestViewModel(); guestViewModel.Name = gs.Name; guestViewModel.GuestId = gs.GuestId.ToString(); guestViewModel.ContactNo = gs.ContactNo; guestViewModel.TableNo = gs.TableNo; guestViewModel.Attendance = gs.Attendance; mylist.Add(guestViewModel); } guestListViewModel.Guest = mylist; return(View("ManageGuestList", guestListViewModel)); }
public JsonResult JFindGuest() { GuestListViewModel guestListViewModel = new GuestListViewModel(); GuestBusinessLayer guestBusinessLayer = new GuestBusinessLayer(); List <Guest> guests = new List <Guest>(); string keyword = ""; if (RouteData.Values["id"] != null) { keyword = RouteData.Values["id"].ToString(); } if (keyword == "all") { guests = guestBusinessLayer.GetGuests(); } else if (keyword != "" && keyword != null) { guests = guestBusinessLayer.FindGuests(keyword); } List <GuestViewModel> mylist = new List <GuestViewModel>(); foreach (Guest gs in guests) { GuestViewModel guestViewModel = new GuestViewModel(); guestViewModel.Name = gs.Name; guestViewModel.GuestId = gs.GuestId.ToString(); guestViewModel.ContactNo = gs.ContactNo; guestViewModel.TableNo = gs.TableNo; guestViewModel.Attendance = gs.Attendance; mylist.Add(guestViewModel); } guestListViewModel.Guest = mylist; return(Json(guestListViewModel.Guest, JsonRequestBehavior.AllowGet)); }
public ActionResult UpdateAttd() { string attendanceId = Request.Form["Attendance"]; string GuestIdForAttd = Request.Form["GuestIdForAttd"]; string FromPage = Request.Form["FromPage"]; if (attendanceId == null) { attendanceId = "0"; } char[] delimiterChars = { ' ', ',', '.', ':', '\t' }; string[] arrayGuestIdForAttd = GuestIdForAttd.Split(delimiterChars); string[] arrayAttendance = attendanceId.Split(delimiterChars); bool foundFlag = false; GuestListViewModel guestListViewModel = new GuestListViewModel(); GuestBusinessLayer guestBusinessLayer = new GuestBusinessLayer(); if (attendanceId != "0") { for (int i = 0; i < arrayGuestIdForAttd.Length; i++) { foundFlag = false; for (int j = 0; j < arrayAttendance.Length; j++) { if (arrayGuestIdForAttd[i] == arrayAttendance[j]) { guestBusinessLayer.SetAttd(arrayGuestIdForAttd[i]); foundFlag = true; } } if (!foundFlag) { guestBusinessLayer.DelAttd(arrayGuestIdForAttd[i]); } } } else if (attendanceId == "0") { for (int i = 0; i < arrayGuestIdForAttd.Length; i++) { guestBusinessLayer.DelAttd(arrayGuestIdForAttd[i]); } } Guest guests = new Guest(); List <GuestViewModel> mylist = new List <GuestViewModel>(); foreach (string s in arrayGuestIdForAttd) { GuestViewModel guestViewModel = new GuestViewModel(); guests = guestBusinessLayer.FindGuestsById(int.Parse(s)); guestViewModel.Name = guests.Name; guestViewModel.GuestId = guests.GuestId.ToString(); guestViewModel.ContactNo = guests.ContactNo; guestViewModel.TableNo = guests.TableNo; guestViewModel.Attendance = guests.Attendance; mylist.Add(guestViewModel); } guestListViewModel.Guest = mylist; if (FromPage == "ManageGuestList") { return(View("ManageGuestList", guestListViewModel)); } else { return(View("Index", guestListViewModel)); } }