Esempio n. 1
0
 public static void Activate(IPeriodRepository periodRep, Period period)
 {
     lock (lockObject)
     {
         bool isActivePeriod = periodRep.GetAll().Any(p => p.Id != period.Id && p.Active);
         if (!isActivePeriod)
         {
             period.Activate();
         }
         else
         {
             throw new PeriodException((int)ApiExceptionCode.CouldNotActivatePeriodWhileExistsAnotherActivePeriod
                                       , ApiExceptionCode.CouldNotActivatePeriodWhileExistsAnotherActivePeriod.DisplayName);
         }
     }
 }