Пример #1
0
        public Hour Add(HourEntryModel hourModel, string professorUser)
        {
            var isAdmin = _userRepository.isAdmin(professorUser);
            var hour    = _hourRepository.InsertHourFromModel(hourModel.AccountId, hourModel.SectionId, hourModel.ProjectId, hourModel.Hour, professorUser, isAdmin);

            _hourRepository.Save();
            return(hour);
        }
        public Hour Add(HourEntryModel hourModel)
        {
            var hour = _hourRepository.InsertHourFromModel(hourModel);

            _hourRepository.Save();
            return(hour);
        }
Пример #3
0
        public HourDto Create(TimeSpan time, int dayOfWeek, bool isEnabled, int campId)
        {
            try
            {
                Helper.TryParseEnum <DayOfWeek>(dayOfWeek - 1, "Día de la semana inválido");
                Camp camp = campRepository.Get(campId);
                Helper.ThrowIfNull(camp, "Datos de cancha inválida.");
                Helper.ThrowIf(!camp.IsEnabled, "Cancha no disponible por el momento.");
                Helper.ThrowIf(hourRepository.Exists(time, dayOfWeek, campId), "Ya existe el horario para el día de la semana indicado.");

                Hour hour = new Hour();
                hour.Time      = time;
                hour.DayOfWeek = dayOfWeek;
                hour.IsEnabled = isEnabled;
                hour.Camp      = camp;

                hourRepository.Save(hour);

                return(new HourDto(hour.Id, hour.Time, hour.DayOfWeek, hour.IsEnabled, campId));
            }
            catch
            {
                throw;
            }
        }