public IndividueltArbete.Model.Patient PatientFormView_GetItem([RouteData]int id) { var service = new Service(); try { return service.GetPatient(id); } catch { CustomValidator cv = new CustomValidator(); cv.ErrorMessage = "Ett fel inträffade när patienten skulle skulle hämtas"; cv.IsValid = false; Page.Validators.Add(cv); return null; } }
public void PatientListView_InsertItem(Doctor doctor) { try { var service = new Service(); service.AddDoctor(doctor); Session["a"] = "Läkaren har blivit upplagd!!!"; Response.Redirect("~/Pages/DoctorPages/Listing.aspx"); } catch { CustomValidator cv = new CustomValidator(); cv.ErrorMessage = "Ett fel inträffade när läkaren skulle läggas up"; cv.IsValid = false; Page.Validators.Add(cv); } }