private bool SaveDeadLine(CaseDeadline deadline) { if (deadline != null) { if (workNotificationService.GetJudgeUserId(deadline.CaseId) == null) { return(false); } deadline.UserId = userContext.UserId; deadline.DateWrt = DateTime.Now; if ((deadline.CourtId ?? 0) <= 0) { deadline.CourtId = userContext.CourtId; } if (deadline.DateComplete == null && deadline.DateExpired == null) { var workNotification = workNotificationService.NewWorkNotification(deadline); if (workNotification != null) { workNotification.CaseDeadline = deadline; if (workNotification.Id == 0) { repo.Add(workNotification); } else { repo.Update(workNotification); } } else { if (deadline.Id == 0) { repo.Add(deadline); } else { repo.Update(deadline); } } return(true); } if (deadline.DateComplete != null || deadline.DateExpired != null) { if (deadline.Id == 0) { repo.Add(deadline); } else { repo.Update(deadline); } ExpireWorkNotifications(deadline); } } return(false); }
private bool SaveDeadLine(CaseDeadline deadline) { if (deadline != null) { if (workNotificationService.GetJudgeUserId(deadline.CaseId) == null) { return(false); } deadline.UserId = userContext.UserId; deadline.DateWrt = DateTime.Now; if ((deadline.CourtId ?? 0) <= 0) { deadline.CourtId = userContext.CourtId; } if (deadline.DateComplete == null && deadline.DateExpired == null) { var workNotification = workNotificationService.NewWorkNotification(deadline); if (workNotification != null) { workNotification.CaseDeadline = deadline; if (workNotification.Id == 0) { repo.Add(workNotification); } else { repo.Update(workNotification); } } else { if (deadline.Id == 0) { repo.Add(deadline); } else { repo.Update(deadline); } } return(true); } if (deadline.DateComplete != null || deadline.DateExpired != null) { if (deadline.Id == 0) { repo.Add(deadline); } else { repo.Update(deadline); } var workNotifications = repo.AllReadonly <WorkNotification>() .Where(x => x.CaseDeadlineId == deadline.Id && x.DateExpired == null) .ToList(); foreach (var workNotification in workNotifications) { workNotification.DateExpired = deadline.DateExpired ?? deadline.DateComplete; workNotification.DescriptionExpired = deadline.DescriptionExpired; workNotification.UserExpiredId = deadline.UserExpiredId ?? deadline.UserId; repo.Update(workNotification); } } } return(false); }