public ActionResult DeleteConfirmed(DeleteAttendanceNote model)
        {
            model.AttendanceNote = db.AttendanceNotes.Find(model.DeleteModelID);
            int    tipstaffRecordID = model.AttendanceNote.tipstaffRecordID;
            string controller       = genericFunctions.TypeOfTipstaffRecord(tipstaffRecordID);

            db.AttendanceNotes.Remove(model.AttendanceNote);
            db.SaveChanges();
            //get the Audit Event we just created
            string     recDeleted = model.DeleteModelID.ToString();
            AuditEvent AE         = db.AuditEvents.Where(a => a.auditEventDescription.AuditDescription == "AttendanceNote deleted" && a.RecordChanged == recDeleted).OrderByDescending(a => a.EventDate).Take(1).Single();

            //add a deleted reason
            AE.DeletedReasonID = model.DeletedReasonID;
            //and save again
            db.SaveChanges();
            return(RedirectToAction("Details", controller, new { id = tipstaffRecordID }));
        }
        public ActionResult Delete(int id)
        {
            DeleteAttendanceNote model = new DeleteAttendanceNote(id);

            if (model.AttendanceNote == null)
            {
                ErrorModel errModel = new ErrorModel(2);
                errModel.ErrorMessage  = string.Format("Attendance Note {0} has been deleted, please raise a help desk call if you think this has been deleted in error.", id);
                TempData["ErrorModel"] = errModel;
                return(RedirectToAction("IndexByModel", "Error", new { area = "", model = errModel ?? null }));
            }
            if (model.AttendanceNote.tipstaffRecord.caseStatus.sequence > 3)
            {
                TempData["UID"] = model.AttendanceNote.tipstaffRecord.UniqueRecordID;
                return(RedirectToAction("ClosedFile", "Error"));
            }

            return(View(model));
        }