UpdateRestaurant() public method

public UpdateRestaurant ( RestaurantBasicData restaurant ) : void
restaurant Spontaneous.DataModel.RestaurantBasicData
return void
        /// <summary>
        /// Find or fix cuisine and operator for all restaurants from Sweden and Finland
        /// </summary>
        public void SwedenFinlandUpdateCuisines()
        {
            log.InfoFormat("[SwedenFinlandUpdateCuisines].");
            RestaurantsSearch searchUtility = new RestaurantsSearch();
            var allRests = searchUtility.FindAllSwedenFinlandRestaurantsWithCusine();
            ServiceLayerImpl serviceLayer = new ServiceLayerImpl();
            int foundCuisines = 0, notFoundCuisine = 0;
            foreach (var rest in allRests)
            {
                string restName = rest.Name != null ? rest.Name : "";
                string restDescription = rest.Description != null ? rest.Description : "";

                List<CuisineMap> cuisineMaps = cuisineServices.CuisineMapSearch(rest, "Finland");
                if (cuisineMaps != null && cuisineMaps.Count > 0)
                {
                    string cuisinesList = rest.Cuisines != null ? String.Join(", ", rest.Cuisines.ToArray()) : "Empty";
                    log.InfoFormat("[SwedenFinlandUpdateCuisines] Cuisine found. Cuisines list={0}, Cuisine.Count={1}, Restaurant.Name={2}, Restaurant.Description={3}.", cuisinesList, cuisineMaps.Count, restName, restDescription);
                    serviceLayer.UpdateRestaurant(rest);
                    foundCuisines++;
                }
                else 
                {
                    log.InfoFormat("[SwedenFinlandUpdateCuisines] Cuisine not found. Restaurant.Name={0}, Restaurant.Id={1}, Restaurant.Description={2}.", restName, rest.Id.ToString(), restDescription);
                    notFoundCuisine++;
                }
            }
            log.InfoFormat("[SwedenFinlandUpdateCuisines] foundCuisines={0}, notFoundCuisine={1}, allRests={2}.", foundCuisines, notFoundCuisine, allRests.Count);
        }
        /// <summary>
        /// Find or fix cuisine and operator for all restaurants from Osm source
        /// </summary>
        public void UpdateCuisinesAndOperators() 
        {
            log.InfoFormat("[UpdateCuisinesAndOperators].");
            //var allRests = GetAllRestaurantsWithOsmSource();
            var allRests = restaurantsSearchUtilty.FindAllRestaurantsWithCusine();
            ServiceLayerImpl serviceLayer = new ServiceLayerImpl();
            foreach (var rest in allRests)
            {
                string restName = rest.Name != null ? rest.Name : "";
                string restDescription = rest.Description != null ? rest.Description : "";
                //var operatorMap = operatorSevices.OperatorMapSearch(rest);
                //if (operatorMap != null)
                //{
                //    log.InfoFormat("[UpdateCuisinesAndOperators] Operator found. Operator={0}, Restaurant.Name={1}, Restaurant.Description={2}.", operatorMap.Name, restName, restDescription);
                //}

                List<CuisineMap> cuisineMaps = cuisineServices.CuisineMapSearch(rest);
                if (cuisineMaps != null && cuisineMaps.Count > 0)
                {
                    string cuisinesList = rest.Cuisines != null ? String.Join(", ", rest.Cuisines.ToArray()) : "Empty";
                    log.InfoFormat("[UpdateCuisinesAndOperators] Cuisine found. Cuisines list={0}, Cuisine.Count={1}, Restaurant.Name={2}, Restaurant.Description={3}.", cuisinesList, cuisineMaps.Count, restName, restDescription);
                    serviceLayer.UpdateRestaurant(rest);
                }
            }
        }
        public void AddDefaultsMenus(List<RestaurantBasicData> restList) 
        {
            ServiceLayerImpl serviceLayer = new ServiceLayerImpl();
            int AddMenuCount = 0;
            int notNullMenuCount = 0;
            int notFoundDefMenuCount = 0;

            if (restList != null && restList.Count > 0) 
            {
                foreach (var rest in restList)
                {
                    var TempMenus = GetDefaultMenusList(rest);
                    if (TempMenus != null && TempMenus.Count > 0)
                    {
                        //if (rest.Menu != null && rest.Menu.MenuParts != null &&  (rest.Menu.MenuParts.Count == 0 || (rest.Menu.MenuParts.Count == 1 && rest.Menu.MenuParts[0].Name.IndexOf("כל המנות") >= 0))) //|| rest.UpdatedBy == "Back office")
                        if (rest.Menu != null && rest.Menu.MenuParts != null && rest.Menu.MenuParts.Count == 0)
                        {
                            AddMenuCount++;
                            ////If Menu contain "כל המנות" MenuPart combine it with other menus
                            //if (rest.Menu.MenuParts[0].Name.IndexOf("כל המנות") >= 0) 
                            //{
                            //    TempMenus.Add(rest.Menu);
                            //}

                            rest.Menu = CombineMenus(TempMenus);
                            string cuisineName = rest.Cuisine != null ? rest.Cuisine : "";
                            string cuisinesList = rest.Cuisines != null ? String.Join(", ", rest.Cuisines.ToArray()) : "Empty";
                            log.InfoFormat("[AddDefaultsMenus] Found default Menu and rest has null menu, for rest.Name={0}, Cuisine={1}, Cuisines List={2}.", rest.Name, cuisineName, cuisinesList);
                            //rest.UpdatedBy = "SupervisedCuisine_2014.05.29";
                            //rest.UpdatedBy = "AutoFoundCuisine_2014.06.12";
                            rest.UpdateDishesLocation();
                            serviceLayer.UpdateRestaurant(rest);
                        }
                        else
                        {
                            if (rest.Menu != null)
                            {
                                notNullMenuCount++;
                                string cuisineName = rest.Cuisine != null ? rest.Cuisine : "";
                                log.InfoFormat("[AddDefaultsMenus] Found default Menu and rest has Not null menu, for Cuisine={0}, rest.Name={1}.", cuisineName, rest.Name);
                            }
                        }
                    }
                    else
                    {
                        notFoundDefMenuCount++;
                        string cuisineName = rest.Cuisine != null ? rest.Cuisine : "";
                        log.InfoFormat("[AddDefaultsMenus] Not found default menu for Cuisine={0}, rest.Name={1}.", cuisineName, rest.Name);
                    }
                }
            }
            log.InfoFormat("[AddDefaultsMenus] Added menu to restaurants, count={0}.", AddMenuCount);
            log.InfoFormat("[AddDefaultsMenus] Found Cuisine for rest and rest.Menu was NOT empty count={0}.", notNullMenuCount);
            log.InfoFormat("[AddDefaultsMenus] Not found default menu count={0}.", notFoundDefMenuCount);
        }
        public void AddDefaultsMenusToSwedenFinlandRests(List<RestaurantBasicData> restList)
        {
            ServiceLayerImpl serviceLayer = new ServiceLayerImpl();
            int AddMenuCount = 0;
            //int notNullMenuCount = 0;
            int notFoundDefMenuCount = 0;

            Menu finnishDefaultMenu = GetDefaultMenuFromCuisinesList(new List<string>() { "finnish_finland_sweden" });

            if (restList != null && restList.Count > 0)
            {
                foreach (var rest in restList)
                {
                    var TempMenus = GetDefaultMenusList(rest);
                    if (TempMenus != null && TempMenus.Count > 0)
                    {
                        //if (rest.Menu != null && rest.Menu.MenuParts != null && rest.Menu.MenuParts.Count == 0)
                        //{
                            AddMenuCount++;
                            rest.Menu = CombineMenus(TempMenus);
                            string cuisineName = rest.Cuisine != null ? rest.Cuisine : "";
                            string cuisinesList = rest.Cuisines != null ? String.Join(", ", rest.Cuisines.ToArray()) : "Empty";
                            log.InfoFormat("[AddDefaultsMenusToSwedenFinlandRests] Found default Menu and rest has null menu, for rest.Name={0}, Cuisine={1}, Cuisines List={2}.", rest.Name, cuisineName, cuisinesList);
                            //rest.UpdatedBy = "SupervisedCuisine_2014.05.29";
                            //rest.UpdatedBy = "AutoFoundCuisine_2014.06.12";
                            rest.UpdateDishesLocation();
                            serviceLayer.UpdateRestaurant(rest);
                        //}
                        //else
                        //{
                        //    if (rest.Menu != null)
                        //    {
                        //        notNullMenuCount++;
                        //        string cuisineName = rest.Cuisine != null ? rest.Cuisine : "";
                        //        log.InfoFormat("[AddDefaultsMenusToSwedenFinlandRests] Found default Menu and rest has Not null menu, for Cuisine={0}, rest.Name={1}.", cuisineName, rest.Name);
                        //    }
                        //}
                    }
                    else
                    {
                        notFoundDefMenuCount++;
                        string cuisineName = rest.Cuisine != null ? rest.Cuisine : "";
                        log.InfoFormat("[AddDefaultsMenusToSwedenFinlandRests] Not found default menu, added default Finnish menu, rest.Name={0}.", rest.Name);
                        rest.Menu = finnishDefaultMenu;
                        rest.UpdateDishesLocation();
                        serviceLayer.UpdateRestaurant(rest);
                    }
                }
            }
            log.InfoFormat("[AddDefaultsMenusToSwedenFinlandRests] Added menu to restaurants, count={0}.", AddMenuCount);
            //log.InfoFormat("[AddDefaultsMenusToSwedenFinlandRests] Found Cuisine for rest and rest.Menu was NOT empty count={0}.", notNullMenuCount);
            log.InfoFormat("[AddDefaultsMenusToSwedenFinlandRests] Not found default menu count={0}.", notFoundDefMenuCount);
        }
        public void AddDefaultMenuToRestaurant(RestaurantBasicData rest) 
        {
            try
            {
                if (rest != null)
                {
                    string cuisinesList = rest.Cuisines != null ? String.Join(", ", rest.Cuisines.ToArray()) : "Empty";
                    var TempMenus = GetDefaultMenusList(rest);
                    if (TempMenus != null && TempMenus.Count > 0)
                    {
                        ServiceLayerImpl serviceLayer = new ServiceLayerImpl();
                        rest.Menu = CombineMenus(TempMenus);
                        log.InfoFormat("[AddDefaultMenuToRestaurant] Found default Menu for rest.Name={0}, rest.Id={1}, Cuisines List={2}.", rest.Name, rest.Id.ToString(), cuisinesList);
                        rest.UpdateDishesLocation();
                        serviceLayer.UpdateRestaurant(rest);
                    }
                    else 
                    {
                        log.InfoFormat("[AddDefaultMenuToRestaurant] Not found default Menu for rest.Name={0}, rest.Id={1}, Cuisines List={2}.", rest.Name, rest.Id.ToString(), cuisinesList);
                    }

                }
                else 
                {
                    log.WarnFormat("[AddDefaultMenuToRestaurant] input restayrant is null.");
                }
            }
            catch (Exception e) 
            {
                log.ErrorFormat("[AddDefaultMenuToRest] Exception={0}.", e.Message);
            }
        }