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); }
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); }
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; } }