public void ChainEditTest()
        {
            ChainEdit editProperties = new ChainEdit()
            {
                QueryString = "donald",
                EmptyMenu = true,

            };

            chainUtility.ChainEdit(editProperties);
        }
        public void ChainEdit(ChainEdit editProperties)
        {
            try
            {
                if (editProperties != null && editProperties.QueryString != null)
                {

                    var restsList = restaurantsSearchUtilty.FindAllRestaurantsByOperator(editProperties.QueryString, editProperties.EmptyMenu);
                    if (restsList != null)
                    {
                        log.InfoFormat("[ChainEdit] editProperties.QueryString={0}, editProperties.EmptyMenu={1}, restsList.Count={2}.", editProperties.QueryString, editProperties.EmptyMenu.ToString(), restsList.Count);
                        RestaurantBasicData patternRest = null;
                        if (editProperties.PatternId != null && !string.IsNullOrEmpty(editProperties.PatternId))
                        {
                            patternRest = serviceLayer.GetRestaurantBasicById(editProperties.PatternId);
                        }

                        ImageServices m_imageService = new ImageServices();
                        DefaultMenuUtility defMenuUtil = new DefaultMenuUtility();

                        foreach (var rest in restsList)
                        {
                            bool updateFlag = false;

                            if (!string.IsNullOrEmpty(editProperties.ChainName))
                            {
                                rest.Operator = editProperties.ChainName;
                                updateFlag = true;
                            }
                            //update chain logo
                            if (editProperties.LogoUpdate && !string.IsNullOrEmpty(editProperties.Logo))
                            {
                                m_imageService.UploadImageToRestaurant(rest, editProperties.Logo);
                            }

                            if (editProperties.CuisineUpdate && !string.IsNullOrEmpty(editProperties.Cuisine))
                            {
                                if (rest.Cuisines == null) rest.Cuisines = new List<string>();
                                rest.Cuisines.Add(editProperties.Cuisine);
                                updateFlag = true;
                            }

                            if (editProperties.DefaultMenuCopy)
                            {
                                defMenuUtil.AddDefaultMenuToRestaurant(rest);
                                updateFlag = false;
                            }

                            if (patternRest != null)
                            {
                                if (editProperties.MenuCopyFlag && patternRest.Menu != null)
                                {
                                    rest.Menu = patternRest.Menu;
                                    updateFlag = true;
                                }

                                //Copy image from pattern restuarant
                                if (editProperties.LogoCopyFlag && patternRest.Image != null)
                                {
                                    rest.Image = patternRest.Image;
                                    updateFlag = true;
                                }
                            }

                            // Save updates in DB
                            if (updateFlag) serviceLayer.UpdateRestaurant(rest);
                        }

                    }

                }
                else
                {
                    log.WarnFormat("[ChainEdit] editProperties is null.");
                }
            }
            catch (Exception e)
            {
                log.ErrorFormat("[ChainEdit] Exception={0}.", e.Message);
            }
        }
        public ActionResult ChainEdit(ChainEdit editParameters)
        {
            log.InfoFormat("[ChainEdit].");
            if (ModelState.IsValid)
            {
                RestuarntsChainUtility chainUtility = new RestuarntsChainUtility();
                chainUtility.ChainEdit(editParameters);
                return RedirectToAction("Index");
            }

            return View(editParameters);
        }