コード例 #1
0
        private void recordPlan(vmDayByDayPlan model)
        {
            Plan newPlan = new Plan();

            newPlan.PlanName       = "Plan" + AccountUser.User.UserName + AccountUser.Account.AccountID;
            newPlan.PlanDate       = DateTime.Now;
            newPlan.PlanPopularity = int.Parse(model.Popularity);
            dalplan.RecordPlan(newPlan.PlanName, newPlan.PlanDate, newPlan.PlanPopularity, model.ProvinceID, AccountUser.Account.AccountID);
            model.PlanID = dalplan.GetLastPlanID();
        }
コード例 #2
0
        public ActionResult GetPlan()
        {
            vmDayByDayPlan Model = new vmDayByDayPlan();

            if (TempData.Count != 0)
            {
                var model = TempData["ExistPlan"] as vmDayByDayPlan;
                return(View(model));
            }
            return(View(Model));
        }
コード例 #3
0
 public bool PlaceControl(vmDayByDayPlan model, Place Place)
 {
     foreach (var item in model.Plan)
     {
         if (item.place.PlaceID == Place.PlaceID)
         {
             return(false);
         }
     }
     return(true);
 }
コード例 #4
0
 public void RecordActivities(vmDayByDayPlan model)
 {
     foreach (var item in model.Plan)
     {
         Activity act = new Activity();
         act.ActivityID         = int.Parse(item.ActivityID);
         act.ActivityName       = "Activity" + model.Plan.IndexOf(item) + AccountUser.User.UserName + AccountUser.Account.AccountID;
         act.ActivityType       = item.ActivityPlaceType;
         act.ActivityStartTime  = DateTime.Today + item.StartTime;
         act.ActivityFinishTime = DateTime.Today + item.FinishTime;
         act.ActivityComplete   = true;
         act.ActivityPlaceID    = item.place.PlaceID;
         DALAct.Add(act.ActivityID, act.ActivityName, act.ActivityType, act.ActivityStartTime, act.ActivityFinishTime, Convert.ToInt32(act.ActivityComplete), act.ActivityPlaceID, model.PlanID);
     }
 }
コード例 #5
0
        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);
        }
コード例 #6
0
        public ActionResult DayByDay(pmPlanCriteria param)
        {
            vmDayByDayPlan Model = bllplan.GetvmDayByDay(param);

            return(View(Model));
        }
コード例 #7
0
        public ActionResult PlanDirections(string PlanID)
        {
            vmDayByDayPlan model = bllplan.GetExistPlan(int.Parse(PlanID));

            return(View(model));
        }
コード例 #8
0
ファイル: BLLPlan.cs プロジェクト: atakaank/DayScheduling
        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);
        }