/// <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; } }
/// <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; } }
/// <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); }