public static string BookAppointment(TurnDetailsDTO appointment)
        {
            try
            {
                ActivityTimeDTO activityTime = ActivityTimeBL.GetActivityTime(appointment.EstimatedHour, appointment.ServiceId);

                customersInLine turn = new customersInLine()
                {
                    activityTimeId = activityTime.ActivityTimeId,
                    custId         = appointment.CustId,
                    estimatedHour  = appointment.EstimatedHour,
                    preAlert       = appointment.PreAlert,
                    statusTurn     = (int)eStatus.ADVANCE,
                    enterHour      = ConfigureHour(appointment.EstimatedHour, activityTime),
                    isActive       = true
                };
                turn.TurnId = TurnDal.AddAppointment(turn);
                string verificationCode = TurnBL.CreateVerificationCode(turn);
                turn.verificationCode = verificationCode;
                TurnDal.UpdateTurn(turn);
                return(verificationCode);
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #2
0
        public static TurnDetailsDTO GetNearestTurn(int serviceId)
        {
            try
            {
                ActivityTimeDTO        activityTime = ActivityTimeBL.GetActivityTime(DateTime.Now, serviceId);
                List <customersInLine> line         = new List <customersInLine>();
                if (activityTime != null)
                {
                    line = TurnDal.GetLinePerActivityTime(activityTime.ActivityTimeId);
                    if (line.Count() == 0)
                    {
                        throw new Exception("there is no turns now");
                    }
                }


                else
                {
                    throw new Exception("there is no activityTime now");
                }
                if (line[0].actualHour == null)
                {
                    line[0].actualHour = new TimeSpan();
                }
                return(converters.TurnDetailsConverters.GetTurnDetailsDTO(line[0]));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="businessId"></param>
        /// <returns>optional hour for immidate turn for the required business</returns>
        public static TimeSpan GetOptionalHourPerBusiness(int serviceId, TimeSpan timeToLookFor, ref bool pushFlag)
        {
            //to ask: ... לכתוב את החילוץ פעמיים
            DateTime time = DateTime.Now;

            time = time.Add(timeToLookFor - time.TimeOfDay);
            ActivityTimeDTO activityTime = ActivityTimeBL.GetActivityTime(time, serviceId);

            if (activityTime == null)
            {
                return(new TimeSpan());
            }
            return((TimeSpan)lookForAvailableTurn(activityTime, ref pushFlag, timeToLookFor));
        }
        /// <summary>
        /// הפונקציה קובעת תור זמני עבור שעה אופציונלית בעסק
        /// </summary>
        /// <param name="turn"></param>
        /// <returns>turn id</returns>
        public static int MakeTemporaryTurn(TurnInBusinessDTO turn, bool pushFlag, int custId)
        {
            DateTime        time         = DateTime.Now;
            ActivityTimeDTO activityTime = ActivityTimeBL.GetActivityTime(time.Add(turn.EstimatedHour.Value - time.TimeOfDay), turn.ServiceId);

            if (activityTime == null)
            {
                throw new Exception("אין משמרת פעילה כרגע");
            }

            //todoever: להחליף בהמשך לאינדקסים
            try
            {
                int status = (int)eStatus.TEMPORARY;
                if (pushFlag)
                {
                    status = (int)eStatus.TEMPORARY_WITH_PUSH;
                }
                customersInLine temporaryTurn = new customersInLine()
                {
                    activityTimeId = activityTime.ActivityTimeId,
                    custId         = custId,
                    enterHour      = TimeSpan.FromMinutes(turn.Duration).Add(DateTime.Now.TimeOfDay),
                    estimatedHour  = DateTime.Today.Add(turn.EstimatedHour.Value),
                    isActive       = true,
                    preAlert       = 0,
                    statusTurn     = status
                };

                int turnId = TurnDal.AddAppointment(temporaryTurn);
                return(turnId);
            }
            catch (Exception)
            {
                throw;
            }
        }