Ejemplo n.º 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;
            }
        }
Ejemplo n.º 2
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);
        }