public static List <DateTime> GetOptionalDaysPerService(int serviceId) { int day = (int)DateTime.Today.DayOfWeek + 1; DateTime date = DateTime.Now; List <activityTime> activityTimes = ActivityTimeDal.GetActivityTimes(serviceId); List <DateTime> optionalDays = new List <DateTime>(); var service = ServiceDal.GetServiceById(serviceId); int limitDays; if (service.kindOfPermission == true) { limitDays = service.limitDays.Value; } else { throw new Exception("בעסק זה לא ניתן לקבוע תורים מראש"); } for (int i = 0; i < limitDays; i++, day++) { if (day == 7) { day = 1; i++; limitDays++; } if (activityTimes.FirstOrDefault(a => a.dayInWeek == day) != null) { optionalDays.Add(date.AddDays(i)); } } return(optionalDays); }
public static TurnInBusinessDTO GetPossibleBusinessWithHour(int serviceId, string latitude, string longitude, bool isDriving, int custId) { bool pushFlag = false; TurnInBusinessDTO service = new TurnInBusinessDTO(); service = converters.TurnInBusinessConverters.GetTurnInBusinessDTO(ServiceDal.GetServiceById(serviceId)); if (latitude != "0" && longitude != "0") { service.Duration = TurnServices.GooglePlaces(longitude, latitude, service.Address, isDriving); } else { service.Duration = 0; } service.EstimatedHour = ImmediateTurn.GetOptionalHourPerBusiness(serviceId, TimeSpan.FromMinutes(service.Duration).Add(DateTime.Now.TimeOfDay), ref pushFlag); try { if (service.EstimatedHour != new TimeSpan()) { service.TurnId = ImmediateTurn.MakeTemporaryTurn(service, pushFlag, custId); } } catch (Exception ex) { throw ex; } return(service); }