public vmPartialActivity getAlcoholActivity(pmPlanCriteria param, string Alcoholtype, string type) { vmPartialActivity alcoholActivity = new vmPartialActivity(); Place alcoholPlace = new Place(); if (Alcoholtype == "40") { alcoholPlace = DALPlace.getTavernPlace(param.ProvinceId, param.BudgetInfo, param.style, param.NumberOfFriends); } if (Alcoholtype == "50") { alcoholPlace = DALPlace.getBarPlace(param.ProvinceId, param.BudgetInfo, param.style, param.NumberOfFriends); } else if (Alcoholtype == "60") { alcoholPlace = DALPlace.getClubPlace(param.ProvinceId, param.BudgetInfo, param.style, param.NumberOfFriends); } if (alcoholPlace != null) { alcoholActivity.place = alcoholPlace; alcoholActivity.ActivityPlaceType = type; return(alcoholActivity); } return(null); }
public ActionResult GetExistActivity(int ActivityID) { vmPartialActivity activity = bllact.GetExistActivity(ActivityID); var res = new { PlaceID = activity.place.PlaceID, PlaceName = activity.place.PlaceName, PlaceRate = activity.place.PlaceRate, Activitytype = activity.ActivityPlaceType }; return(Json(res, JsonRequestBehavior.AllowGet)); }
public vmPartialActivity GetActivitytoChange(int BudgetInfo, int NumOfFriends, string PlaceType, int ProvinceID, string Popularity, TimeSpan OldActivityStartTime, string rate) { vmPartialActivity activity = new vmPartialActivity(); pmPlanCriteria param = new pmPlanCriteria(); param.ProvinceId = ProvinceID; param.style = Popularity; param.BudgetInfo = BudgetInfo; if (PlaceType == "3" || PlaceType == "11" || PlaceType == "12" || PlaceType == "13" || PlaceType == "15" || PlaceType == "30") { if (PlaceType == "3" && OldActivityStartTime < new TimeSpan(16, 0, 0)) activity = getFoodActivity(param, PlaceType, "food"); activity.StartTime = new TimeSpan(16, 0, 0); } else if (PlaceType == "40" || PlaceType == "50" || PlaceType == "60") { if (((PlaceType == "40" || PlaceType == "50") && OldActivityStartTime < new TimeSpan(16, 0, 0))) { activity = getAlcoholActivity(param, PlaceType, "alcohol"); activity.StartTime = new TimeSpan(16, 0, 0); } else if((PlaceType == "60" && (OldActivityStartTime < new TimeSpan(20, 0, 0)))) { activity = getAlcoholActivity(param, PlaceType, "alcohol"); activity.StartTime = new TimeSpan(20, 0, 0); } } else if (PlaceType == "10") { if (OldActivityStartTime > new TimeSpan(10, 0, 0)) return null; activity = getBreakfastActivity(param, OldActivityStartTime, "food"); } else if (PlaceType == "1") { activity = getFunActivity(param, "Fun"); } else if (PlaceType == "2") { activity = getShoppingActivity(param, "Shopping"); } else if (PlaceType == "3") { activity = getBeachActivity(param, "Beach"); } else if (PlaceType == "4") { activity = getOutdoorActivity(param, "Outdoor"); } else if (PlaceType == "5") { activity = getRelaxingActivity(param, "Relaxing"); } else if (PlaceType == "6") { activity = getCulturelActivity(param, "Culturel"); } return activity; }
public ActionResult ChangeActivity(int ActivityID, int BudgetInfo, int NumOfFriends, string PlaceType, int ProvinceID, string Popularity, string rate) { //bllact.DeleteActivity(int.Parse(param.updatePlaceID)); vmPartialActivity existAct = bllact.GetExistActivity(ActivityID); vmPartialActivity newAct = bllact.GetActivitytoChange(BudgetInfo, NumOfFriends, PlaceType, ProvinceID, Popularity, existAct.StartTime, rate); var res = new { activityID = newAct.ActivityID, PlaceID = newAct.place.PlaceID, PlaceName = newAct.place.PlaceName, PlaceRate = newAct.place.PlaceRate, Activitytype = newAct.ActivityPlaceType }; return(Json(res, JsonRequestBehavior.AllowGet)); }
public vmPartialActivity GetExistActivity(int ActivityID) { Activity existActivity = DALAct.Get(ActivityID); vmPartialActivity act = new vmPartialActivity(); act.ActivityPlaceType = existActivity.ActivityType; act.place = DALPlace.Get(existActivity.ActivityPlaceID); act.StartTime = existActivity.ActivityStartTime.TimeOfDay; act.FinishTime = existActivity.ActivityFinishTime.TimeOfDay; return act; }
//public vmPartialActivity getHistoricSitesActivity(pmPlanCriteria param, string type) //{ // vmPartialActivity historicSitesActivity = new vmPartialActivity(); // Place placeHistoricSite = DALPlace.getHistoricSites(param.ProvinceId); // if (placeHistoricSite != null) // { // historicSitesActivity.place = placeHistoricSite; // historicSitesActivity.ActivityPlaceType = type; // return historicSitesActivity; // } // return null; //} public vmPartialActivity getFunActivity(pmPlanCriteria param, string type) { vmPartialActivity FunActivity = new vmPartialActivity(); Place placeFun = DALPlace.getFunPlace(param.ProvinceId, param.BudgetInfo, param.style, param.NumberOfFriends, param.RateDecision); if (placeFun != null) { FunActivity.place = placeFun; FunActivity.ActivityPlaceType = type; return FunActivity; } return null; }
public vmPartialActivity getOutdoorActivity(pmPlanCriteria param, string type) { vmPartialActivity OutdoorActivity = new vmPartialActivity(); Place placeOutdoor = DALPlace.getOutdoorPlace(param.ProvinceId, param.RateDecision); if (placeOutdoor != null) { OutdoorActivity.place = placeOutdoor; OutdoorActivity.ActivityPlaceType = type; return OutdoorActivity; } return null; }
public vmPartialActivity getRelaxingActivity(pmPlanCriteria param, string type) { vmPartialActivity RelaxingActivity = new vmPartialActivity(); Place placeRelaxing = DALPlace.getRelaxingPlace(param.ProvinceId, param.RateDecision); if (placeRelaxing != null) { RelaxingActivity.place = placeRelaxing; RelaxingActivity.ActivityPlaceType = type; return RelaxingActivity; } return null; }
public vmPartialActivity getBeachActivity(pmPlanCriteria param, string type) { vmPartialActivity BeachActivity = new vmPartialActivity(); Place placeBeach = DALPlace.getBeachPlace(param.ProvinceId, param.RateDecision); if (placeBeach != null) { BeachActivity.place = placeBeach; BeachActivity.ActivityPlaceType = type; return BeachActivity; } return null; }
public vmPartialActivity getCulturelActivity(pmPlanCriteria param, string type) { vmPartialActivity culturelActivity = new vmPartialActivity(); Place placeCulture = DALPlace.getCulturelPlace(param.ProvinceId, param.RateDecision); if (placeCulture != null) { culturelActivity.place = placeCulture; culturelActivity.ActivityPlaceType = type; return culturelActivity; } return null; }
public vmPartialActivity getShoppingActivity(pmPlanCriteria param, string type) { vmPartialActivity shoppingActivity = new vmPartialActivity(); Place placeShopping = DALPlace.getShoppingPlace(param.ProvinceId); if (placeShopping != null) { shoppingActivity.place = placeShopping; shoppingActivity.ActivityPlaceType = type; return(shoppingActivity); } return(null); }
public vmPartialActivity getHistoricSitesActivity(pmPlanCriteria param, string type) { vmPartialActivity historicSitesActivity = new vmPartialActivity(); Place placeHistoricSite = DALPlace.getHistoricSites(param.ProvinceId); if (placeHistoricSite != null) { historicSitesActivity.place = placeHistoricSite; historicSitesActivity.ActivityPlaceType = type; return(historicSitesActivity); } return(null); }
public vmPartialActivity getBreakfastActivity(pmPlanCriteria param, TimeSpan currentTime, string type) { vmPartialActivity breakfastActivity = new vmPartialActivity(); Place placeBreakfast = DALPlace.getBreakfastPlace(param.ProvinceId, param.BudgetInfo, param.style, param.NumberOfFriends, param.RateDecision); if (placeBreakfast != null) { breakfastActivity.place = placeBreakfast; breakfastActivity.StartTime = currentTime; breakfastActivity.FinishTime = breakfastActivity.StartTime.Add(TimeSpan.FromHours(breakfastActivity.place.RecommendedDuration)); breakfastActivity.ActivityPlaceType = type; return breakfastActivity; } return null; }
public List<vmPartialActivity> GetActivities(int PlanID) { List<vmPartialActivity> Plan = new List<vmPartialActivity>(); List<Activity> activityList = DALAct.GetList(PlanID); activityList.OrderBy(x => x.ActivityID); foreach (var item in activityList) { vmPartialActivity vmAct = new vmPartialActivity(); vmAct.ActivityID = item.ActivityID.ToString(); vmAct.ActivityPlaceType = item.ActivityType; vmAct.place = DALPlace.Get(item.ActivityPlaceID); vmAct.PlanID = item.PlanID; Plan.Add(vmAct); } return Plan; }
public vmDayByDayPlan GetExistPlan(int PlanID) { vmDayByDayPlan model = new vmDayByDayPlan(); vmPartialActivity currentAct = new vmPartialActivity(); model.Plan = bllAct.GetActivities(PlanID); LocationManager locationManager = new LocationManager(); DirectionLatLong direction = new DirectionLatLong(); model.CurrentTime = model.StartTime; model.PlanID = model.Plan[0].PlanID; //Act olmadığı için. model.ProvinceID = model.Plan[0].place.ProvinceID; model.Province = Enum.GetName(typeof(Provinces), model.Plan[0].place.ProvinceID); model.Plan[0].StartTime = model.CurrentTime; model.Plan[0].FinishTime = model.Plan[0].StartTime.Add(TimeSpan.FromHours(model.Plan[0].place.RecommendedDuration)); model.CurrentTime = model.Plan[0].FinishTime; LatLong firstItemLatLong = locationManager.GetLatLong(model.Plan[0].place.PlaceName + " " + model.Plan[0].place.PlaceAddress); model.Plan[0].DestLat = firstItemLatLong.lat; model.Plan[0].DestLong = firstItemLatLong.Long; for (int i = 1; i < model.Plan.Count; i++) { currentAct = model.Plan[i]; direction = locationManager.getDirection(model.Plan[i - 1].place.PlaceName + " " + model.Plan[i - 1].place.PlaceAddress, currentAct.place.PlaceName + " " + currentAct.place.PlaceAddress); currentAct.SourceLat = direction.SourceLat; currentAct.SourceLong = direction.SourceLong; currentAct.DestLat = direction.DestinationLat; currentAct.DestLong = direction.DestinationLong; currentAct.DirectionDuration = direction.Duration; model.CurrentTime = model.CurrentTime.Add(TimeSpan.FromMinutes(int.Parse(direction.Duration.Substring(0, direction.Duration.IndexOf(" "))))); if (model.CurrentTime <= new TimeSpan(model.CurrentTime.Hours, 30, 0)) { currentAct.StartTime = new TimeSpan(model.CurrentTime.Hours, 30, 0); } else if (model.CurrentTime <= new TimeSpan(model.CurrentTime.Hours + 1, 0, 0) && model.CurrentTime > new TimeSpan(model.CurrentTime.Hours, 30, 0)) { currentAct.StartTime = new TimeSpan(model.CurrentTime.Hours + 1, 0, 0); } currentAct.FinishTime = currentAct.StartTime.Add(TimeSpan.FromHours(currentAct.place.RecommendedDuration)); model.CurrentTime = currentAct.FinishTime; } return(model); }
public vmPartialActivity getFoodActivity(pmPlanCriteria param, string foodType, string type) { vmPartialActivity foodActivity = new vmPartialActivity(); Place foodPlace = new Place(); if (foodType == "3") { foodPlace = DALPlace.getRestaurantPlace(param.ProvinceId, param.BudgetInfo, param.style, param.NumberOfFriends); } if (foodType == "11") { foodPlace = DALPlace.getFastFoodPlace(param.ProvinceId, param.BudgetInfo, param.style, param.NumberOfFriends); } else if (foodType == "12") { foodPlace = DALPlace.getMeatChickenPlace(param.ProvinceId, param.BudgetInfo, param.style, param.NumberOfFriends); } if (foodType == "13") { foodPlace = DALPlace.getSeaFoodPlace(param.ProvinceId, param.BudgetInfo, param.style, param.NumberOfFriends); } if (foodType == "15") { foodPlace = DALPlace.getHomemadePlace(param.ProvinceId, param.BudgetInfo, param.style, param.NumberOfFriends); } if (foodType == "30") { foodPlace = DALPlace.getDesertPlace(param.ProvinceId, param.BudgetInfo, param.style, param.NumberOfFriends); } if (foodPlace != null) { foodActivity.place = foodPlace; foodActivity.ActivityPlaceType = type; return(foodActivity); } return(null); }
public vmDayByDayPlan GetvmDayByDay(pmPlanCriteria param) { LocationManager locationManager = new LocationManager(); Dictionary <string, string> MustDoList = new Dictionary <string, string>(); Place currentPlace = new Place(); for (int i = 0; i < param.categoryGroupNames.Count && param.categoryGroupNames != null; i++) { MustDoList.Add(param.categoryGroupNames.ElementAt(i), param.categoryGroupNames.ElementAt(i)); } if (!string.IsNullOrEmpty(param.FoodCategory)) { MustDoList.Add("food", param.FoodCategory); } if (!string.IsNullOrEmpty(param.AlcoholCategory)) { MustDoList.Add("alcohol", param.AlcoholCategory); } Random rnd = new Random(); vmDayByDayPlan model = new vmDayByDayPlan(); model.Province = Enum.GetName(typeof(Provinces), param.ProvinceId); model.ProvinceID = param.ProvinceId; model.Plan = new List <vmPartialActivity>(); model.TravelList = new List <Travel>(); model.CurrentTime = model.StartTime; model.Popularity = param.style; recordPlan(model); //dalplan.RecordPlantoHistory(AccountUser.Account.AccountID, model.PlanID); while (MustDoList.Count != 0) // model.CurrentTime <= new TimeSpan(19,0,0) && hepsi yapılmışsa ve saat en az 19.00'u geçmişse. Hepsi yapılmış ve 19.00u geçmemişse yine random bir category seçilir. { Travel travel = new Travel(); vmPartialActivity currentAct = new vmPartialActivity(); DirectionLatLong direction = new DirectionLatLong(); if (param.FoodCategory == "10" && model.CurrentTime == model.StartTime) { currentAct = bllAct.getBreakfastActivity(param, model.CurrentTime, "food"); if (currentAct != null) { model.CurrentTime = currentAct.FinishTime; MustDoList.Remove("food"); model.Plan.Add(currentAct); currentAct.ActivityID = model.PlanID.ToString() + model.Plan.IndexOf(currentAct).ToString(); //ActivityID } } int index = rnd.Next(0, MustDoList.Count - 1); if (MustDoList.ElementAt(index).Key == "culture") { currentAct = bllAct.getCulturelActivity(param, "Culture"); if (currentAct != null) { if (model.Plan.Count != 0) //ondan önce activityler varsa ilk activity değilse. { direction = locationManager.getDirection(model.Plan[model.Plan.Count - 1].place.PlaceName + " " + model.Plan[model.Plan.Count - 1].place.PlaceAddress, currentAct.place.PlaceName + " " + currentAct.place.PlaceAddress); currentAct.SourceLat = direction.SourceLat; currentAct.SourceLong = direction.SourceLong; currentAct.DestLat = direction.DestinationLat; currentAct.DestLong = direction.DestinationLong; currentAct.DirectionDuration = direction.Duration; model.CurrentTime = model.CurrentTime.Add(TimeSpan.FromMinutes(int.Parse(direction.Duration.Substring(0, direction.Duration.IndexOf(" "))))); if (model.CurrentTime <= new TimeSpan(model.CurrentTime.Hours, 30, 0)) { currentAct.StartTime = new TimeSpan(model.CurrentTime.Hours, 30, 0); } else if (model.CurrentTime <= new TimeSpan(model.CurrentTime.Hours + 1, 0, 0) && model.CurrentTime > new TimeSpan(model.CurrentTime.Hours, 30, 0)) { currentAct.StartTime = new TimeSpan(model.CurrentTime.Hours + 1, 0, 0); } currentAct.FinishTime = currentAct.StartTime.Add(TimeSpan.FromHours(currentAct.place.RecommendedDuration)); model.CurrentTime = currentAct.FinishTime; MustDoList.Remove("culture"); model.TravelList.Add(travel); } else { currentAct.StartTime = model.CurrentTime; currentAct.FinishTime = currentAct.StartTime.Add(TimeSpan.FromHours(currentAct.place.RecommendedDuration)); model.CurrentTime = currentAct.FinishTime; MustDoList.Remove("culture"); } model.Plan.Add(currentAct); currentAct.ActivityID = model.PlanID.ToString() + model.Plan.IndexOf(currentAct).ToString(); //ActivityID } else { MustDoList.Remove("culture");// nullsa da kaldırılması gerekiyor çünkü seçilen semtte kritere uygun mekan yok demektir ve kriter kaldırılır. } } else if (MustDoList.ElementAt(index).Key == "Shopping") { currentAct = bllAct.getShoppingActivity(param, "Shopping"); // Place bulamazsa activity null döncek. if (currentAct != null) // null değilse zaten time güncellenip activity eklenecek. { if (model.Plan.Count != 0) //ondan önce activityler varsa ilk activity değilse. { direction = locationManager.getDirection(model.Plan[model.Plan.Count - 1].place.PlaceName + " " + model.Plan[model.Plan.Count - 1].place.PlaceAddress, currentAct.place.PlaceName + " " + currentAct.place.PlaceAddress); //adress yapılcak. currentAct.SourceLat = direction.SourceLat; currentAct.SourceLong = direction.SourceLong; currentAct.DestLat = direction.DestinationLat; currentAct.DestLong = direction.DestinationLong; currentAct.DirectionDuration = direction.Duration; model.CurrentTime = model.CurrentTime.Add(TimeSpan.FromMinutes(int.Parse(direction.Duration.Substring(0, direction.Duration.IndexOf(" "))))); if (model.CurrentTime <= new TimeSpan(model.CurrentTime.Hours, 30, 0)) { currentAct.StartTime = new TimeSpan(model.CurrentTime.Hours, 30, 0); } else if (model.CurrentTime <= new TimeSpan(model.CurrentTime.Hours + 1, 0, 0) && model.CurrentTime > new TimeSpan(model.CurrentTime.Hours, 30, 0)) { currentAct.StartTime = new TimeSpan(model.CurrentTime.Hours + 1, 0, 0); } currentAct.FinishTime = currentAct.StartTime.Add(TimeSpan.FromHours(currentAct.place.RecommendedDuration)); model.CurrentTime = currentAct.FinishTime; MustDoList.Remove("Shopping"); model.TravelList.Add(travel); } else { currentAct.StartTime = model.CurrentTime; currentAct.FinishTime = currentAct.StartTime.Add(TimeSpan.FromHours(currentAct.place.RecommendedDuration)); model.CurrentTime = currentAct.FinishTime; MustDoList.Remove("Shopping"); } model.Plan.Add(currentAct); currentAct.ActivityID = model.PlanID.ToString() + model.Plan.IndexOf(currentAct).ToString(); //ActivityID } else { MustDoList.Remove("Shopping");// nullsa da kaldırılması gerekiyor çünkü seçilen semtte kritere uygun mekan yok demektir ve kriter kaldırılır. } } else if (MustDoList.ElementAt(index).Key == "Historic Sites") { currentAct = bllAct.getHistoricSitesActivity(param, "Historic Sites"); if (currentAct != null) { if (model.Plan.Count != 0) //ondan önce activityler varsa ilk activity değilse. { direction = locationManager.getDirection(model.Plan[model.Plan.Count - 1].place.PlaceName + " " + model.Plan[model.Plan.Count - 1].place.PlaceAddress, currentAct.place.PlaceName + " " + currentAct.place.PlaceAddress); //adress yapılcak. currentAct.SourceLat = direction.SourceLat; currentAct.SourceLong = direction.SourceLong; currentAct.DestLat = direction.DestinationLat; currentAct.DestLong = direction.DestinationLong; currentAct.DirectionDuration = direction.Duration; model.CurrentTime = model.CurrentTime.Add(TimeSpan.FromMinutes(int.Parse(direction.Duration.Substring(0, direction.Duration.IndexOf(" ")))));// Replace(" mins", "")))); if (model.CurrentTime <= new TimeSpan(model.CurrentTime.Hours, 30, 0)) { currentAct.StartTime = new TimeSpan(model.CurrentTime.Hours, 30, 0); } else if (model.CurrentTime <= new TimeSpan(model.CurrentTime.Hours + 1, 0, 0) && model.CurrentTime > new TimeSpan(model.CurrentTime.Hours, 30, 0)) { currentAct.StartTime = new TimeSpan(model.CurrentTime.Hours + 1, 0, 0); } currentAct.FinishTime = currentAct.StartTime.Add(TimeSpan.FromHours(currentAct.place.RecommendedDuration)); model.CurrentTime = currentAct.FinishTime; MustDoList.Remove("Historic Sites"); model.TravelList.Add(travel); } else { currentAct.StartTime = model.CurrentTime; currentAct.FinishTime = currentAct.StartTime.Add(TimeSpan.FromHours(currentAct.place.RecommendedDuration)); model.CurrentTime = currentAct.FinishTime; MustDoList.Remove("Historic Sites"); } model.Plan.Add(currentAct); currentAct.ActivityID = model.PlanID.ToString() + model.Plan.IndexOf(currentAct).ToString(); //ActivityID } else { MustDoList.Remove("Historic Sites");// nullsa da kaldırılması gerekiyor çünkü seçilen semtte kritere uygun mekan yok demektir ve kriter kaldırılır. } } else if (MustDoList.ElementAt(index).Key == "fun") { currentAct = bllAct.getFunActivity(param, "Fun"); if (currentAct != null) { if (model.Plan.Count != 0) //ondan önce activityler varsa ilk activity değilse. { direction = locationManager.getDirection(model.Plan[model.Plan.Count - 1].place.PlaceName + " " + model.Plan[model.Plan.Count - 1].place.PlaceAddress, currentAct.place.PlaceName + " " + currentAct.place.PlaceAddress); //adress yapılcak. currentAct.SourceLat = direction.SourceLat; currentAct.SourceLong = direction.SourceLong; currentAct.DestLat = direction.DestinationLat; currentAct.DestLong = direction.DestinationLong; currentAct.DirectionDuration = direction.Duration; model.CurrentTime = model.CurrentTime.Add(TimeSpan.FromMinutes(int.Parse(direction.Duration.Substring(0, direction.Duration.IndexOf(" "))))); if (model.CurrentTime <= new TimeSpan(model.CurrentTime.Hours, 30, 0)) { currentAct.StartTime = new TimeSpan(model.CurrentTime.Hours, 30, 0); } else if (model.CurrentTime <= new TimeSpan(model.CurrentTime.Hours + 1, 0, 0) && model.CurrentTime > new TimeSpan(model.CurrentTime.Hours, 30, 0)) { currentAct.StartTime = new TimeSpan(model.CurrentTime.Hours + 1, 0, 0); } currentAct.FinishTime = currentAct.StartTime.Add(TimeSpan.FromHours(currentAct.place.RecommendedDuration)); model.CurrentTime = currentAct.FinishTime; MustDoList.Remove("fun"); model.TravelList.Add(travel); } else { currentAct.StartTime = model.CurrentTime; currentAct.FinishTime = currentAct.StartTime.Add(TimeSpan.FromHours(currentAct.place.RecommendedDuration)); model.CurrentTime = currentAct.FinishTime; MustDoList.Remove("fun"); } model.Plan.Add(currentAct); currentAct.ActivityID = model.PlanID.ToString() + model.Plan.IndexOf(currentAct).ToString(); //ActivityID } else { MustDoList.Remove("fun");// nullsa da kaldırılması gerekiyor çünkü seçilen semtte kritere uygun mekan yok demektir ve kriter kaldırılır. } } else if (MustDoList.ElementAt(index).Key == "Beaches") { currentAct = bllAct.getBeachActivity(param, "Beaches"); if (currentAct != null) { if (model.Plan.Count != 0) //ondan önce activityler varsa ilk activity değilse. { direction = locationManager.getDirection(model.Plan[model.Plan.Count - 1].place.PlaceName + " " + model.Plan[model.Plan.Count - 1].place.PlaceAddress, currentAct.place.PlaceName + " " + currentAct.place.PlaceAddress); //adress yapılcak. currentAct.SourceLat = direction.SourceLat; currentAct.SourceLong = direction.SourceLong; currentAct.DestLat = direction.DestinationLat; currentAct.DestLong = direction.DestinationLong; currentAct.DirectionDuration = direction.Duration; model.CurrentTime = model.CurrentTime.Add(TimeSpan.FromMinutes(int.Parse(direction.Duration.Substring(0, direction.Duration.IndexOf(" "))))); if (model.CurrentTime <= new TimeSpan(model.CurrentTime.Hours, 30, 0)) { currentAct.StartTime = new TimeSpan(model.CurrentTime.Hours, 30, 0); } else if (model.CurrentTime <= new TimeSpan(model.CurrentTime.Hours + 1, 0, 0) && model.CurrentTime > new TimeSpan(model.CurrentTime.Hours, 30, 0)) { currentAct.StartTime = new TimeSpan(model.CurrentTime.Hours + 1, 0, 0); } currentAct.FinishTime = currentAct.StartTime.Add(TimeSpan.FromHours(currentAct.place.RecommendedDuration)); model.CurrentTime = currentAct.FinishTime; MustDoList.Remove("Beaches"); model.TravelList.Add(travel); } else { currentAct.StartTime = model.CurrentTime; currentAct.FinishTime = currentAct.StartTime.Add(TimeSpan.FromHours(currentAct.place.RecommendedDuration)); model.CurrentTime = currentAct.FinishTime; MustDoList.Remove("Beaches"); } model.Plan.Add(currentAct); currentAct.ActivityID = model.PlanID.ToString() + model.Plan.IndexOf(currentAct).ToString(); //ActivityID } else { MustDoList.Remove("Beaches");// nullsa da kaldırılması gerekiyor çünkü seçilen semtte kritere uygun mekan yok demektir ve kriter kaldırılır. } } else if (MustDoList.ElementAt(index).Key == "unwind") { currentAct = bllAct.getRelaxingActivity(param, "Relaxing"); if (currentAct != null) { if (model.Plan.Count != 0) //ondan önce activityler varsa ilk activity değilse. { direction = locationManager.getDirection(model.Plan[model.Plan.Count - 1].place.PlaceName + " " + model.Plan[model.Plan.Count - 1].place.PlaceAddress, currentAct.place.PlaceName + " " + currentAct.place.PlaceAddress); //adress yapılcak. currentAct.SourceLat = direction.SourceLat; currentAct.SourceLong = direction.SourceLong; currentAct.DestLat = direction.DestinationLat; currentAct.DestLong = direction.DestinationLong; currentAct.DirectionDuration = direction.Duration; model.CurrentTime = model.CurrentTime.Add(TimeSpan.FromMinutes(int.Parse(direction.Duration.Substring(0, direction.Duration.IndexOf(" "))))); if (model.CurrentTime <= new TimeSpan(model.CurrentTime.Hours, 30, 0)) { currentAct.StartTime = new TimeSpan(model.CurrentTime.Hours, 30, 0); } else if (model.CurrentTime <= new TimeSpan(model.CurrentTime.Hours + 1, 0, 0) && model.CurrentTime > new TimeSpan(model.CurrentTime.Hours, 30, 0)) { currentAct.StartTime = new TimeSpan(model.CurrentTime.Hours + 1, 0, 0); } currentAct.FinishTime = currentAct.StartTime.Add(TimeSpan.FromHours(currentAct.place.RecommendedDuration)); model.CurrentTime = currentAct.FinishTime; MustDoList.Remove("unwind"); model.TravelList.Add(travel); } else { currentAct.StartTime = model.CurrentTime; currentAct.FinishTime = currentAct.StartTime.Add(TimeSpan.FromHours(currentAct.place.RecommendedDuration)); model.CurrentTime = currentAct.FinishTime; MustDoList.Remove("unwind"); } model.Plan.Add(currentAct); currentAct.ActivityID = model.PlanID.ToString() + model.Plan.IndexOf(currentAct).ToString(); //ActivityID } else { MustDoList.Remove("unwind");// nullsa da kaldırılması gerekiyor çünkü seçilen semtte kritere uygun mekan yok demektir ve kriter kaldırılır. } } else if (MustDoList.ElementAt(index).Key == "outdoors") { currentAct = bllAct.getOutdoorActivity(param, "outdoors"); if (currentAct != null) { if (model.Plan.Count != 0) //ondan önce activityler varsa ilk activity değilse. { direction = locationManager.getDirection(model.Plan[model.Plan.Count - 1].place.PlaceName + " " + model.Plan[model.Plan.Count - 1].place.PlaceAddress, currentAct.place.PlaceName + " " + currentAct.place.PlaceAddress); //adress yapılcak. currentAct.SourceLat = direction.SourceLat; currentAct.SourceLong = direction.SourceLong; currentAct.DestLat = direction.DestinationLat; currentAct.DestLong = direction.DestinationLong; currentAct.DirectionDuration = direction.Duration; model.CurrentTime = model.CurrentTime.Add(TimeSpan.FromMinutes(int.Parse(direction.Duration.Substring(0, direction.Duration.IndexOf(" "))))); if (model.CurrentTime <= new TimeSpan(model.CurrentTime.Hours, 30, 0)) { currentAct.StartTime = new TimeSpan(model.CurrentTime.Hours, 30, 0); } else if (model.CurrentTime <= new TimeSpan(model.CurrentTime.Hours + 1, 0, 0) && model.CurrentTime > new TimeSpan(model.CurrentTime.Hours, 30, 0)) { currentAct.StartTime = new TimeSpan(model.CurrentTime.Hours + 1, 0, 0); } currentAct.FinishTime = currentAct.StartTime.Add(TimeSpan.FromHours(currentAct.place.RecommendedDuration)); model.CurrentTime = currentAct.FinishTime; MustDoList.Remove("outdoors"); model.TravelList.Add(travel); } else { currentAct.StartTime = model.CurrentTime; currentAct.FinishTime = currentAct.StartTime.Add(TimeSpan.FromHours(currentAct.place.RecommendedDuration)); model.CurrentTime = currentAct.FinishTime; MustDoList.Remove("outdoors"); } model.Plan.Add(currentAct); currentAct.ActivityID = model.PlanID.ToString() + model.Plan.IndexOf(currentAct).ToString(); //ActivityID } else { MustDoList.Remove("outdoors");// nullsa da kaldırılması gerekiyor çünkü seçilen semtte kritere uygun mekan yok demektir ve kriter kaldırılır. } } else if (MustDoList.ElementAt(index).Key == "food") { bool hourControl = true; currentAct = bllAct.getFoodActivity(param, MustDoList.ElementAt(index).Value, "food"); if (currentAct != null) { if (model.Plan.Count != 0) //ondan önce activityler varsa ilk activity değilse. { if ((currentAct.place.PlaceTypeID == 3 && model.CurrentTime >= new TimeSpan(16, 0, 0)) || currentAct.place.PlaceTypeID != 3) //restaurant olup saat 4ten önce değilse veya restaurant değilse. { direction = locationManager.getDirection(model.Plan[model.Plan.Count - 1].place.PlaceName + " " + model.Plan[model.Plan.Count - 1].place.PlaceAddress, currentAct.place.PlaceName + " " + currentAct.place.PlaceAddress); //adress yapılcak. currentAct.SourceLat = direction.SourceLat; currentAct.SourceLong = direction.SourceLong; currentAct.DestLat = direction.DestinationLat; currentAct.DestLong = direction.DestinationLong; currentAct.DirectionDuration = direction.Duration; model.CurrentTime = model.CurrentTime.Add(TimeSpan.FromMinutes(int.Parse(direction.Duration.Substring(0, direction.Duration.IndexOf(" "))))); if (model.CurrentTime <= new TimeSpan(model.CurrentTime.Hours, 30, 0)) { currentAct.StartTime = new TimeSpan(model.CurrentTime.Hours, 30, 0); } else if (model.CurrentTime <= new TimeSpan(model.CurrentTime.Hours + 1, 0, 0) && model.CurrentTime > new TimeSpan(model.CurrentTime.Hours, 30, 0)) { currentAct.StartTime = new TimeSpan(model.CurrentTime.Hours + 1, 0, 0); } currentAct.FinishTime = currentAct.StartTime.Add(TimeSpan.FromHours(currentAct.place.RecommendedDuration)); model.CurrentTime = currentAct.FinishTime; model.Plan.Add(currentAct); currentAct.ActivityID = model.PlanID.ToString() + model.Plan.IndexOf(currentAct).ToString(); //ActivityID MustDoList.Remove("food"); model.TravelList.Add(travel); } else { hourControl = false; } } else { currentAct.StartTime = model.CurrentTime; currentAct.FinishTime = currentAct.StartTime.Add(TimeSpan.FromHours(currentAct.place.RecommendedDuration)); model.CurrentTime = currentAct.FinishTime; model.Plan.Add(currentAct); currentAct.ActivityID = model.PlanID.ToString() + model.Plan.IndexOf(currentAct).ToString(); //ActivityID MustDoList.Remove("food"); } if (!hourControl && MustDoList.Count == 1 && currentAct.place.PlaceTypeID == 3) // sadece alkol aktivitesi kaldıysa ve o meyhane veya bar ise saat başka aktivite ile artmıcağından saati ileri alıyoruz. { model.CurrentTime = new TimeSpan(16, 0, 0); } } else { MustDoList.Remove("food");// nullsa da kaldırılması gerekiyor çünkü seçilen semtte kritere uygun mekan yok demektir ve kriter kaldırılır. } } else if (MustDoList.ElementAt(index).Key == "alcohol") { bool hourControl = true; //club bar için saatin uygunluğunu detect etmeye yarıyor. currentAct = bllAct.getAlcoholActivity(param, MustDoList.ElementAt(index).Value, "alcohol"); if (currentAct != null) { if (model.Plan.Count != 0) //ondan önce activityler varsa ilk activity değilse. { if (((currentAct.place.PlaceTypeID == 50 || currentAct.place.PlaceTypeID == 40) && model.CurrentTime >= new TimeSpan(16, 0, 0)) || (currentAct.place.PlaceTypeID == 60 && model.CurrentTime >= new TimeSpan(20, 0, 0))) { direction = locationManager.getDirection(model.Plan[model.Plan.Count - 1].place.PlaceName + " " + model.Plan[model.Plan.Count - 1].place.PlaceAddress, currentAct.place.PlaceName + " " + currentAct.place.PlaceAddress); //adress yapılcak. currentAct.SourceLat = direction.SourceLat; currentAct.SourceLong = direction.SourceLong; currentAct.DestLat = direction.DestinationLat; currentAct.DestLong = direction.DestinationLong; currentAct.DirectionDuration = direction.Duration; model.CurrentTime = model.CurrentTime.Add(TimeSpan.FromMinutes(int.Parse(direction.Duration.Substring(0, direction.Duration.IndexOf(" "))))); if (model.CurrentTime <= new TimeSpan(model.CurrentTime.Hours, 30, 0)) { currentAct.StartTime = new TimeSpan(model.CurrentTime.Hours, 30, 0); } else if (model.CurrentTime <= new TimeSpan(model.CurrentTime.Hours + 1, 0, 0) && model.CurrentTime > new TimeSpan(model.CurrentTime.Hours, 30, 0)) { currentAct.StartTime = new TimeSpan(model.CurrentTime.Hours + 1, 0, 0); } currentAct.FinishTime = currentAct.StartTime.Add(TimeSpan.FromHours(currentAct.place.RecommendedDuration)); model.CurrentTime = currentAct.FinishTime; model.Plan.Add(currentAct); currentAct.ActivityID = model.PlanID.ToString() + model.Plan.IndexOf(currentAct).ToString(); //ActivityID MustDoList.Remove("alcohol"); model.TravelList.Add(travel); } else { hourControl = false; // saat uygun değilse false. } } //else //{ // currentAct.StartTime = model.CurrentTime; // currentAct.FinishTime = currentAct.StartTime.Add(TimeSpan.FromHours(currentAct.place.RecommendedDuration)); // ilk aktivite olamaz. // model.CurrentTime = currentAct.FinishTime; // MustDoList.Remove("alcohol"); //} if (!hourControl && MustDoList.Count == 1 && (currentAct.place.PlaceTypeID == 40 || currentAct.place.PlaceTypeID == 50)) // sadece alkol aktivitesi kaldıysa ve o meyhane veya bar ise saat başka aktivite ile artmıcağından saati ileri alıyoruz. { model.CurrentTime = new TimeSpan(16, 0, 0); } else if (!hourControl && MustDoList.Count == 1 && currentAct.place.PlaceTypeID == 60)// sadece alkol aktivitesi kaldıysa ve o club ise saat başka aktivite ile artmıcağından saati ileri alıyoruz. { model.CurrentTime = new TimeSpan(20, 0, 0); } //MustDoList.Remove("alcohol"); //model.Plan.Add(currentAct); } else { MustDoList.Remove("alcohol");// nullsa da kaldırılması gerekiyor çünkü seçilen semtte kritere uygun mekan yok demektir ve kriter kaldırılır. } } //model.CurrentTime = new TimeSpan(19, 30, 0); } bllAct.RecordActivities(model); return(model); }