public void Deactivate(Advice advice) { DeleteJobFromHangfire(advice); advice.IsActive = false; AdviceRepository.Update(advice); AdviceRepository.Save(); }
public void BulkDeleteAdvice(IEnumerable <Advice> toBeDeleted) { using var transaction = TransactionManager.Begin(IsolationLevel.ReadCommitted); foreach (var advice in toBeDeleted) { RemoveAdviceAndItsRelatedEntities(advice); } AdviceRepository.Save(); transaction.Commit(); }
public bool SendAdvice(int id) { using var transaction = TransactionManager.Begin(IsolationLevel.ReadCommitted); try { var advice = AdviceRepository.AsQueryable().ById(id); if (advice != null) { if (advice.AdviceType == AdviceType.Immediate || IsAdviceInScope(advice)) { if (DispatchEmails(advice)) { AdviceRepository.Update(advice); AdviceSentRepository.Insert(new AdviceSent { AdviceId = id, AdviceSentDate = OperationClock.Now }); } } if (advice.AdviceType == AdviceType.Immediate) { advice.IsActive = false; } else if (IsAdviceExpired(advice)) { advice.IsActive = false; DeleteJobFromHangfire(advice); } AdviceRepository.Save(); AdviceSentRepository.Save(); transaction.Commit(); } return(true); } catch (Exception e) { Logger?.Error(e, "General error sending emails in advice service"); transaction.Rollback(); throw; } }
public void Delete(Advice advice) { RemoveAdviceAndItsRelatedEntities(advice); AdviceRepository.Save(); }
public void CreateAdvice(Advice advice) { ScheduleAdvice(advice); AdviceRepository.Update(advice); AdviceRepository.Save(); }