public ActionResult AssignTag(FormCollection collection) { try { var model = new StudentRegistrationModel(); UpdateModel(model); //TODO investigate why Id is getting populated, and RowId is being lost // Need to create a viewModel? Or hide the RowId field in the view? model.RowId = model.Id; var repo = new StudentParkingPermitRepository(); var entity = repo.UpdateParkingTag(model); //var models = GetRegistrations(new List<Admin_Security_ParkingRegistration> { entity }); //TempData["Registrations"] = models; return RedirectToAction("Details", new {id = entity.RowID}); } catch (Exception ex) { // ReSharper disable once UnusedVariable var msg = ex.Message; return View(); } }
private static StudentRegistrationModel GetRegistration(Admin_Security_ParkingRegistration entity) { var date = entity.DateTagIssued?.ToString("d") ?? DateTime.Now.ToString("d"); var model = new StudentRegistrationModel { RowId = entity.RowID.ToString(), AssignedBy = entity.IssuedBy, StudentId = entity.StudentID, TagNumber = entity.TagNumber, FirstName = entity.FirstName, LastName = entity.LastName, Phone = entity.Phone, VehicleType = entity.VehicleType, Make = entity.CarMake, Color = entity.Color, Year = entity.CarYear.ToString(), LicensePlate = entity.LicenseNumber, State = entity.State, Model = entity.CarModel, StudentType = entity.StudentType, ClassYear = entity.ClassYear, ViolationCount = entity.ViolationCount.ToString(), DateTagIssued = date }; return model; }
public ActionResult EditStudentRegistration(string id, FormCollection collection) { try { var model = new StudentRegistrationModel(); UpdateModel(model); var repo = new StudentParkingPermitRepository(); var entity = repo.Update(model); //var models = GetRegistrations(new List<Admin_Security_ParkingRegistration> {entity}); //TempData["Registrations"] = models; //return RedirectToAction("ShowRegistrations"); return RedirectToAction("Details", new {id = entity.RowID}); } catch (Exception ex) { // ReSharper disable once UnusedVariable var msg = ex.Message; return View(); } }