public ActionResult RegisterInvitation(InvitationViewModel invitationViewModel) { if (!ModelState.IsValid) { ViewBag.RegisteredSuccessfully = false; return(View(invitationViewModel)); } var invitation = new Invitation { StudentId = invitationViewModel.StudentId, Name = invitationViewModel.Name, Address = invitationViewModel.Address, NationalId = invitationViewModel.NationalId, BirthDate = invitationViewModel.BirthDate, PlaceOfBirth = invitationViewModel.PlaceOfBirth, Relationship = invitationViewModel.Relationship }; _mtiGraduationPartyEntities.Invitations.Add(invitation); _mtiGraduationPartyEntities.SaveChanges(); TempData["RegisteredSuccessfully"] = true; return(RedirectToAction("RegisterInvitation")); }
public ActionResult RegisterStudent(StudentViewModel studentViewModel) { if (!ModelState.IsValid) { ViewBag.RegisteredSuccessfully = false; studentViewModel.Id = 0; return(View(studentViewModel)); } var student = new Student { Id = studentViewModel.Id, Name = studentViewModel.Name, TableId = studentViewModel.TableId, BusId = studentViewModel.BusId, BreakfastOutlet = studentViewModel.BreakfastOutlet, LunchOutlet = studentViewModel.LunchOutlet }; _mtiGraduationPartyEntities.Students.Add(student); _mtiGraduationPartyEntities.SaveChanges(); TempData["RegisteredSuccessfully"] = true; return(RedirectToAction("RegisterStudent")); }
public ActionResult RegisterAttendance(int invitationId) { string message = "success"; var invitation = _mtiGraduationPartyEntities.Invitations.FirstOrDefault(i => i.Id == invitationId); if (invitation == null) { return(HttpNotFound()); } if (invitation.Attended == true) { message = "attendee Exist"; return(Json(message, JsonRequestBehavior.AllowGet)); } invitation.Attended = true; invitation.PresenceDateTime = DateTime.Now; _mtiGraduationPartyEntities.SaveChanges(); return(Json(message, JsonRequestBehavior.AllowGet)); }