Ejemplo n.º 1
0
        public IHttpActionResult Delete(HolidayType holidayType, string salesAreaName)
        {
            if (string.IsNullOrEmpty(salesAreaName) || !ModelState.IsValid)
            {
                return(this.Error().InvalidParameters());
            }

            var salesArea = _salesAreaRepository.FindByName(salesAreaName);

            if (salesArea == null)
            {
                return(NotFound());
            }

            switch (holidayType)
            {
            case HolidayType.PublicHoliday:
                salesArea.PublicHolidays.Clear();
                break;

            case HolidayType.SchoolHoliday:
                salesArea.SchoolHolidays.Clear();
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(holidayType), holidayType, null);
            }
            _salesAreaRepository.Update(salesArea);
            return(Ok());
        }