Ejemplo n.º 1
0
        /// <summary>
        /// Checks and sets the service hours for out api.
        /// </summary>
        public void CheckServiceHour()
        {
            var hourType = ServiceHoursTypeEnum.Standard;

            Enum.TryParse(ServiceHourType, out hourType);
            switch (hourType)
            {
            case ServiceHoursTypeEnum.Standard:
                // If ValidTo field is null opening hour is valid for now
                if (!ValidTo.HasValue)
                {
                    ValidFrom   = null;
                    ValidForNow = true;
                }
                // Set DayTo as empty. In db DayTo is always 'Monday' - not very logical for end user since the time is supposed to be valid on this certain week day. PTV-3455
                OpeningHour.ForEach(h => { h.DayTo = ""; });
                break;

            case ServiceHoursTypeEnum.Exception:
                // Set DayFrom and DayTo fields as null - in database these fields are not set correctly!
                OpeningHour.ForEach(h => { h.DayFrom = null; h.DayTo = null; });
                break;

            case ServiceHoursTypeEnum.Special:
                // If ValidTo field is null opening hour is valid for now
                if (!ValidTo.HasValue)
                {
                    ValidFrom   = null;
                    ValidForNow = true;
                }
                break;
            }
        }