public IActionResult Delete(string id) { DeviceCalibration ldevice = (from p in context.DeviceCalibration where p.SetupId == id select p).FirstOrDefault(); if (ldevice != null) { int res = lIDeviceCalibrationRepository.deleteDeviceCalibrationCascade(id); if (res > 0) { //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 = "Equipment"; llog.Comment = "Record deleted"; llog.RecordJson = JsonConvert.SerializeObject(ldevice); 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); } } return(RedirectToAction("Index", "Equipment")); }