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 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));
        }