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