Ejemplo n.º 1
0
 public void Deactivate(Advice advice)
 {
     DeleteJobFromHangfire(advice);
     advice.IsActive = false;
     AdviceRepository.Update(advice);
     AdviceRepository.Save();
 }
Ejemplo n.º 2
0
 public void BulkDeleteAdvice(IEnumerable <Advice> toBeDeleted)
 {
     using var transaction = TransactionManager.Begin(IsolationLevel.ReadCommitted);
     foreach (var advice in toBeDeleted)
     {
         RemoveAdviceAndItsRelatedEntities(advice);
     }
     AdviceRepository.Save();
     transaction.Commit();
 }
Ejemplo n.º 3
0
        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;
            }
        }
Ejemplo n.º 4
0
 public void Delete(Advice advice)
 {
     RemoveAdviceAndItsRelatedEntities(advice);
     AdviceRepository.Save();
 }
Ejemplo n.º 5
0
 public void CreateAdvice(Advice advice)
 {
     ScheduleAdvice(advice);
     AdviceRepository.Update(advice);
     AdviceRepository.Save();
 }