예제 #1
0
        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;
            }
        }
예제 #2
0
 /// <summary>
 /// occured whenever turn finished
 /// </summary>
 /// <param name="turn"></param>
 public static void CompleteTurn(TurnDetailsDTO turn)
 {
     try
     {
         customersInLine acceptedTurn = TurnDal.GetTurnByTurnId(turn.TurnId);
         acceptedTurn.exitHour = DateTime.Now.TimeOfDay;
         TurnDal.UpdateTurn(acceptedTurn);
     }
     catch (Exception)
     {
         throw;
     }
 }
        public static customersInLine GetCustomersInLine(TurnDetailsDTO turnDTO)
        {
            customersInLine turn = new customersInLine()
            {
                custId           = turnDTO.CustId,
                estimatedHour    = turnDTO.EstimatedHour,
                actualHour       = turnDTO.ActualHour,
                TurnId           = turnDTO.TurnId,
                verificationCode = turnDTO.VeriverificationCode
            };

            return(turn);
        }
        public static TurnInBusinessDTO GetTurnToShowDTO(customersInLine custTurn)
        {
            TurnInBusinessDTO turn = new TurnInBusinessDTO()
            {
                ServiceId     = custTurn.activityTime.serviceId,
                BusinessName  = custTurn.activityTime.service.business.businessName,
                Address       = custTurn.activityTime.service.business.adress_street + " " + custTurn.activityTime.service.business.adress_numOfStreet + " " + custTurn.activityTime.service.business.adress_city,
                TurnId        = custTurn.TurnId,
                EstimatedHour = custTurn.estimatedHour.TimeOfDay,
                FullTime      = custTurn.estimatedHour,
            };

            return(turn);
        }
예제 #5
0
        /*
         * public static TurnDetailsDTO GetTurnDetailsDTO(customersInLine appointment)
         * {
         *
         *  TurnDetailsDTO turnDetails = new TurnDetailsDTO()
         *  {
         *     ServiceId=appointment.activityTime.serviceId,
         *     PreAlert=appointment.preAlert,
         *     TurnId=appointment.TurnId
         *  };
         *  return turnDetails;
         * }
         *
         * public static List<TurnDetailsDTO> GetTurnsDetailsDTO(List<customersInLine> appointments)
         * {
         *  List<TurnDetailsDTO> line = new List<TurnDetailsDTO>();
         *  appointments.ForEach(a => line.Add(GetTurnDetailsDTO(a)));
         *  return line;
         * }
         */
        #endregion

        #region convert customersInLine to CustomerInLineDTO
        public static CustomerInLineDTO GetCustomerInLineDTO(customersInLine appointment)
        {
            CustomerInLineDTO turnDetails = new CustomerInLineDTO()
            {
                ActivityTimeId = appointment.activityTimeId,
                StatusTurn     = appointment.statusTurn,
                CustId         = appointment.custId,
                PreAlert       = appointment.preAlert,
                TurnId         = appointment.TurnId,
                EstimatedHour  = appointment.estimatedHour
            };

            turnDetails.EstimatedHour.Add(appointment.estimatedHour.TimeOfDay);
            return(turnDetails);
        }
        public static TurnDetailsDTO GetTurnDetailsDTO(customersInLine turn)
        {
            TurnDetailsDTO turnDetails = new TurnDetailsDTO
            {
                CustId               = turn.custId,
                EstimatedHour        = turn.estimatedHour,
                TurnId               = turn.TurnId,
                VeriverificationCode = turn.verificationCode,
                ServiceId            = turn.activityTime.serviceId,
                ActualHour           = turn.actualHour.Value
                                       //ActualHour=new TimeSpan()
            };

            return(turnDetails);
        }
예제 #7
0
        public static customersInLine GetCustomerInLine(CustomerInLineDTO appointment)
        {
            customersInLine customerInLine = new customersInLine()
            {
                actualHour     = appointment.ActualHour,
                activityTimeId = appointment.ActivityTimeId,
                statusTurn     = appointment.StatusTurn,
                custId         = appointment.CustId,
                preAlert       = appointment.PreAlert,
                TurnId         = appointment.TurnId,
                estimatedHour  = appointment.EstimatedHour,
                enterHour      = appointment.EnterHour
            };

            return(customerInLine);
        }
예제 #8
0
 /// <summary>
 /// occured whenever turn accepted
 /// </summary>
 /// <param name="turn"></param>
 public static TurnDetailsDTO AcceptTurn(TurnDetailsDTO turn)
 {
     try
     {
         customersInLine acceptedTurn = TurnDal.GetTurnByTurnId(turn.TurnId);
         if (turn.ActualHour != new TimeSpan() && turn.ActualHour != null)
         {
             acceptedTurn = converters.TurnDetailsConverters.GetCustomersInLine(GetNearestTurn(acceptedTurn.activityTime.serviceId));
         }
         acceptedTurn.actualHour = DateTime.Now.TimeOfDay;
         TurnDal.UpdateTurn(acceptedTurn);
         return(converters.TurnDetailsConverters.GetTurnDetailsDTO(acceptedTurn));
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #9
0
        /// <summary>
        /// function that check if turn is unusual
        /// </summary>
        /// <param name="turn"></param>
        /// <param name="actualDuration"></param>
        /// <param name="IsServiceDuration"></param>
        /// <returns>if+ this turn is unusual</returns>
        private static bool IsSignificantDeviation(customersInLine turn, double actualDuration, bool IsServiceDuration)
        {
            double currentLen;

            if (IsServiceDuration == true)
            {
                currentLen = (turn.exitHour.Value - turn.actualHour.Value).TotalMinutes;
            }
            else
            {
                currentLen = turn.numOfPushTimes.Value;
            }

            if (currentLen * 1.3 < actualDuration || currentLen * 0.7 > actualDuration)
            {
                return(true);
            }
            return(false);
        }
예제 #10
0
        /// <summary>
        /// confirm the turn and add it to the table
        /// </summary>
        /// <param name="turn"></param>
        /// <returns></returns>

        public static confirmResponse ConfirmImmediateTurn(TurnDetailsDTO turn)
        {
            List <customersInLine> line = new List <customersInLine>();


            customersInLine newTurn = TurnDal.GetTurnByTurnId(turn.TurnId);

            line = TurnDal.GetLineByCustomer(newTurn.custId).Where(l => l.statusTurn == (int)eStatus.TEMPORARY || l.statusTurn == (int)eStatus.TEMPORARY_WITH_PUSH).ToList();
            var x = line.Remove(line.First(t => t.TurnId == turn.TurnId));

            if (newTurn.statusTurn == (int)eStatus.TEMPORARY_WITH_PUSH)
            {
                pushTurns(TurnDal.GetLinePerActivityTime(newTurn.activityTime.serviceId), newTurn.estimatedHour.TimeOfDay, ActivityTimeConverters.GetActivityTimeDTO(newTurn.activityTime));
            }
            newTurn.statusTurn = (int)eStatus.IMMEDIATELY;
            string verificationCode = TurnBL.CreateVerificationCode(newTurn);

            newTurn.verificationCode = verificationCode;
            newTurn.preAlert         = turn.PreAlert;
            TurnDal.UpdateTurn(newTurn);
            if (line.Count() > 0)
            {
                line.ForEach(a => TurnDal.DeleteTurn(a.TurnId));
            }
            //טיפול במקרי קצה של תורים באותה שעה
            var allTurnsToCus = BL.CustInLineBL.GetTurnsToCustomer(newTurn.custId);

            allTurnsToCus = allTurnsToCus.Where(t => t.FullTime == newTurn.estimatedHour && t.TurnId != newTurn.TurnId).ToList();

            confirmResponse confirmResponse = new DTO.confirmResponse()
            {
                turnId           = turn.TurnId,
                verificationCode = verificationCode,
                isConflict       = allTurnsToCus.Count != 0 ? true : false
            };


            return(confirmResponse);
        }
예제 #11
0
        /// <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;
            }
        }
예제 #12
0
        public static string CreateVerificationCode(customersInLine turn)
        {
            string code = "" + turn.TurnId + turn.custId;

            return(code);
        }