Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
 public static void DeleteTurn(int turnId)
 {
     TurnDal.DeleteTurn(turnId);
 }