//delete the patient record public IActionResult Delete(int patid) { try { Patient lpatient = context.Patient.FirstOrDefault(p => p.PatientId == patid); if (lpatient != null) { string result = lIPatientRxRepository.DeletePatientRecordsWithCasecade(patid); if (!string.IsNullOrEmpty(result) && result == "success") { //Insert to User Activity Log UserActivityLog llog = new UserActivityLog(); llog.SessionId = HttpContext.Session.GetString("SessionId"); llog.ActivityType = "Update"; llog.StartTimeStamp = !string.IsNullOrEmpty(HttpContext.Session.GetString("SessionTime")) ? Convert.ToDateTime(HttpContext.Session.GetString("SessionTime")) : DateTime.Now; llog.Duration = Convert.ToInt32((DateTime.Now - Convert.ToDateTime(HttpContext.Session.GetString("SessionTime"))).TotalSeconds); llog.RecordChangeType = "Delete"; llog.RecordType = "Patient"; llog.Comment = "Record deleted"; llog.RecordJson = JsonConvert.SerializeObject(lpatient); llog.UserId = HttpContext.Session.GetString("UserId"); llog.UserName = HttpContext.Session.GetString("UserName"); llog.UserType = HttpContext.Session.GetString("UserType"); if (!string.IsNullOrEmpty(HttpContext.Session.GetString("ReviewID"))) { llog.ReviewId = HttpContext.Session.GetString("ReviewID"); } lIUserActivityLogRepository.InsertUserActivityLog(llog); } } } catch (Exception ex) { logger.LogDebug("Error: " + ex); } if (!string.IsNullOrEmpty(HttpContext.Session.GetString("UserType")) && HttpContext.Session.GetString("UserType") == "0") { return(RedirectToAction("Index", "Patient")); } if (!string.IsNullOrEmpty(HttpContext.Session.GetString("UserType")) && HttpContext.Session.GetString("UserType") == "1") { return(RedirectToAction("Dashboard", "Support")); } if (!string.IsNullOrEmpty(HttpContext.Session.GetString("UserType")) && HttpContext.Session.GetString("UserType") == "2") { return(RedirectToAction("Dashboard", "Therapist")); } if (!string.IsNullOrEmpty(HttpContext.Session.GetString("UserType")) && HttpContext.Session.GetString("UserType") == "3") { return(RedirectToAction("Dashboard", "Provider")); } else { return(RedirectToAction("Dashboard", "Provider")); } }