예제 #1
0
        public Hour Update(UpdateHourCommand command)
        {
            var Hour = _repository.Get(command.Id);

            Hour.Update(command.HourOfDay, command.Active, command.Reserved, command.DayId);
            _repository.Update(Hour);

            if (Commit())
            {
                return(Hour);
            }

            return(null);
        }
예제 #2
0
        public Hour Update(long hourId, HourEntryModel hourModel)
        {
            var hour = _hourRepository.Get(hourId);

            if (hour.SectionProject.IsApproved)
            {
                throw new HoursAlreadyApprovedException("Las Horas no se pueden modificar porque ya han sido aprobadas");
            }
            hour.Amount = hourModel.Hour;
            _hourRepository.Update(hour);
            _hourRepository.Save();
            return(hour);
        }
예제 #3
0
 public void EnableDisable(int hourId, bool isEnabled)
 {
     try
     {
         hourRepository.TransactionManager.BeginTransaction();
         Hour hour = hourRepository.Get(hourId);
         Helper.ThrowIfNull(hour, "El horario no existe.");
         Helper.ThrowIf(hour.IsEnabled == isEnabled, "El horario ya se encuentra " + (isEnabled ? "habilitado" : "deshabilitado"));
         hour.IsEnabled = isEnabled;
         hourRepository.SaveOrUpdate(hour);
         hourRepository.TransactionManager.CommitTransaction();
     }
     catch
     {
         hourRepository.TransactionManager.RollbackTransaction();
         throw;
     }
 }