public bool CreateAttendance(AttendanceCreate model) { var entity = new Attendance() { OwnerID = _userID, CarID = model.CarID, MeetID = model.MeetID, }; using (var ctx = new ApplicationDbContext()) { ctx.Attendances.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult Create(AttendanceCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateAttendanceService(); if (service.CreateAttendance(model)) { TempData["SaveResult"] = "Your Attendance Has Been Created!"; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Your Attendance Could Not Be Created"); return(View(model)); }
public ActionResult Create(AttendanceCreate model) { ViewBag.CharacterID = CharacterSelect(model.CharacterID); ViewBag.CombatID = CombatSelect(model.CombatID); if (!ModelState.IsValid) { return(View(model)); } var svc = CreateAttendanceService(); if (svc.CreateAttendance(model)) { TempData["SaveResult"] = "Character Successfully Added to Encounter"; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Character could not be added to encounter."); return(View(model)); }