Пример #1
0
        private void CloneNowMenuBased(string fromCycle, string menuCodes, string toCycle)
        {
            this.InvokeEx(f => f.lblStatus.Visible = true);
            this.InvokeEx(f => f.lblStatus.Text    = "In Progress, please wait!");
            this.InvokeEx(f => f.btnSubmit.Enabled = false);

            var newClonedMenus = _menuManagement.CloneMenuCodesToNewCycle(fromCycle, menuCodes, toCycle);

            ChiliProcessor chili = new ChiliProcessor();

            foreach (var key in newClonedMenus.Keys)
            {
                var newMenuID = key;
                var oldMenuId = newClonedMenus[key];

                var newMenu = _menuManagement.GetMenuById(newMenuID);

                var menuCode = "MNU" + Helper.Get8Digits();
                menuCode = MenuProcessor.GenerateMenuCode(Convert.ToInt32(newMenu.MenuTypeId), menuCode);

                var newMenuCodeWeek = menuCode;

                //only food guide will not have _1

                if (newMenu.MenuTypeId != 5)
                {
                    newMenuCodeWeek += "_1";
                }

                _menuManagement.UpdateMenuCode(newMenuID, newMenuCodeWeek);

                var newDOc = chili.CloneChiliDocument(oldMenuId);

                var oldMenuTemplate = _menuManagement.GetMenuTemplate(oldMenuId);
                _menuManagement.UpdateMenuTemplate(newMenuID, oldMenuTemplate.TemplateID, newDOc);


                //apply cycle menucode chili variable in chii doc
                _menuProcessor.RebuildFlightNumberLotNumberChiliVariableForMenu(newMenuID);
            }

            this.InvokeEx(f => f.lblStatus.Visible = true);
            this.InvokeEx(f => f.lblStatus.Text    = "Menu cloning has been completed successfully!");
            this.InvokeEx(f => f.btnSubmit.Enabled = true);

            MessageBox.Show("Menu cloning has been completed successfully!");
        }