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; } }
public IHttpActionResult ConfirmTurn([FromBody] TurnDetailsDTO turn) { try { return(Ok(ImmediateTurn.ConfirmImmediateTurn(turn))); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
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); }
/// <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 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); }
public IHttpActionResult BookAppointment(HttpRequestMessage request, [FromBody] TurnDetailsDTO appointment) { String access_token = request.Headers.Authorization.ToString(); int custId = Token.GetCustIdFromToken(access_token); appointment.CustId = custId; try { return(Ok(MakeAppointment.BookAppointment(appointment))); } catch { return(BadRequest()); } }
/// <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); }