Esempio n. 1
0
 public ActionResult Edit(ClientMenuManageModel model, SubmitTypeEnums submit)
 {
     if (ModelState.IsValid)
     {
         var response = _clientMenuServices.SaveClientMenuManageModel(model);
         if (response.Success)
         {
             SetSuccessMessage(response.Message);
             switch (submit)
             {
                 case SubmitTypeEnums.Save:
                     return RedirectToAction("Index");
                 default:
                     return RedirectToAction("Edit", new { id = model.Id });
             }
         }
         SetErrorMessage(response.Message);
     }
     model.Parents = _clientMenuServices.GetPossibleParents();
     return View(model);
 }
Esempio n. 2
0
        public ActionResult Edit(ClientMenuManageModel model, SubmitTypeEnums submit)
        {
            if (ModelState.IsValid)
            {
                var response = _clientMenuServices.SaveClientMenuManageModel(model);
                if (response.Success)
                {
                    SetSuccessMessage(response.Message);
                    switch (submit)
                    {
                    case SubmitTypeEnums.Save:
                        return(RedirectToAction("Index"));

                    default:
                        return(RedirectToAction("Edit", new { id = model.Id }));
                    }
                }
                SetErrorMessage(response.Message);
            }
            model.Parents = _clientMenuServices.GetPossibleParents();
            return(View(model));
        }
Esempio n. 3
0
        /// <summary>
        /// Save client menu manage model
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ResponseModel SaveClientMenuManageModel(ClientMenuManageModel model)
        {
            ClientMenu relativeMenu;
            ResponseModel response;
            var clientMenu = GetById(model.Id);

            #region Edit ClientMenu
            if (clientMenu != null)
            {
                clientMenu.Name = model.Name;

                clientMenu.IncludeInSiteNavigation = model.IncludeInSiteNavigation;
                clientMenu.StartPublishingDate = model.StartPublishingDate;
                clientMenu.EndPublishingDate = model.EndPublishingDate;

                //Parse url
                clientMenu.Url = string.IsNullOrWhiteSpace(model.Url)
                                       ? model.Name.ToUrlString()
                                       : model.Url.ToUrlString();

                //Get page record order
                relativeMenu = GetById(model.RelativeMenuId);
                if (relativeMenu != null)
                {
                    if (model.Position == (int)ClientMenuEnums.PositionEnums.Before)
                    {
                        clientMenu.RecordOrder = relativeMenu.RecordOrder;
                        var query =
                            string.Format(
                                "Update ClientMenus set RecordOrder = RecordOrder + 1 Where {0} And RecordOrder >= {1}",
                                relativeMenu.ParentId.HasValue ? string.Format(" ParentId = {0}", relativeMenu.ParentId) : "ParentId Is NULL", relativeMenu.RecordOrder);
                        _pageRepository.ExcuteSql(query);
                    }
                    else
                    {
                        clientMenu.RecordOrder = relativeMenu.RecordOrder + 1;
                        var query =
                            string.Format(
                                "Update ClientMenus set RecordOrder = RecordOrder + 1 Where {0} And RecordOrder > {1}",
                                relativeMenu.ParentId.HasValue ? string.Format(" ParentId = {0}", relativeMenu.ParentId) : "ParentId Is NULL", relativeMenu.RecordOrder);
                        _pageRepository.ExcuteSql(query);
                    }
                }

                clientMenu.ParentId = model.ParentId;
                response = HierarchyUpdate(clientMenu);

                return response.SetMessage(response.Success ?
                    _localizedResourceServices.T("AdminModule:::ClientMenus:::Messages:::UpdateSuccessfully:::Update client menu successfully.")
                    : _localizedResourceServices.T("AdminModule:::ClientMenus:::Messages:::UpdateFailure:::Update client menu failed. Please try again later."));
            }
            #endregion

            clientMenu = new ClientMenu
            {
                Name = model.Name,
                ParentId = model.ParentId,
                IncludeInSiteNavigation = model.IncludeInSiteNavigation,
                StartPublishingDate = model.StartPublishingDate,
                EndPublishingDate = model.EndPublishingDate,
                Url = string.IsNullOrWhiteSpace(model.Url) ? model.Name.ToUrlString() : model.Url.ToUrlString()
            };

            //Get menu record order
            relativeMenu = GetById(model.RelativeMenuId);
            if (relativeMenu != null)
            {
                if (model.Position == (int)ClientMenuEnums.PositionEnums.Before)
                {
                    clientMenu.RecordOrder = relativeMenu.RecordOrder - 1;
                }
                else
                {
                    clientMenu.RecordOrder = relativeMenu.RecordOrder + 1;
                }
            }

            response = HierarchyInsert(clientMenu);
            return response.SetMessage(response.Success ?
                _localizedResourceServices.T("AdminModule:::ClientMenus:::Messages:::CreateSuccessfully:::Create client menu successfully.")
                : _localizedResourceServices.T("AdminModule:::ClientMenus:::Messages:::CreateFailure:::Create client menu failed. Please try again later."));
        }
Esempio n. 4
0
        /// <summary>
        /// Save client menu manage model
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ResponseModel SaveClientMenuManageModel(ClientMenuManageModel model)
        {
            ClientMenu    relativeMenu;
            ResponseModel response;
            var           clientMenu = GetById(model.Id);

            #region Edit ClientMenu
            if (clientMenu != null)
            {
                clientMenu.Name = model.Name;

                clientMenu.IncludeInSiteNavigation = model.IncludeInSiteNavigation;
                clientMenu.StartPublishingDate     = model.StartPublishingDate;
                clientMenu.EndPublishingDate       = model.EndPublishingDate;

                //Parse url
                clientMenu.Url = string.IsNullOrWhiteSpace(model.Url)
                                       ? model.Name.ToUrlString()
                                       : model.Url.ToUrlString();

                //Get page record order
                relativeMenu = GetById(model.RelativeMenuId);
                if (relativeMenu != null)
                {
                    if (model.Position == (int)ClientMenuEnums.PositionEnums.Before)
                    {
                        clientMenu.RecordOrder = relativeMenu.RecordOrder;
                        var query =
                            string.Format(
                                "Update ClientMenus set RecordOrder = RecordOrder + 1 Where {0} And RecordOrder >= {1}",
                                relativeMenu.ParentId.HasValue ? string.Format(" ParentId = {0}", relativeMenu.ParentId) : "ParentId Is NULL", relativeMenu.RecordOrder);
                        _pageRepository.ExcuteSql(query);
                    }
                    else
                    {
                        clientMenu.RecordOrder = relativeMenu.RecordOrder + 1;
                        var query =
                            string.Format(
                                "Update ClientMenus set RecordOrder = RecordOrder + 1 Where {0} And RecordOrder > {1}",
                                relativeMenu.ParentId.HasValue ? string.Format(" ParentId = {0}", relativeMenu.ParentId) : "ParentId Is NULL", relativeMenu.RecordOrder);
                        _pageRepository.ExcuteSql(query);
                    }
                }

                clientMenu.ParentId = model.ParentId;
                response            = HierarchyUpdate(clientMenu);

                return(response.SetMessage(response.Success ?
                                           _localizedResourceServices.T("AdminModule:::ClientMenus:::Messages:::UpdateSuccessfully:::Update client menu successfully.")
                    : _localizedResourceServices.T("AdminModule:::ClientMenus:::Messages:::UpdateFailure:::Update client menu failed. Please try again later.")));
            }
            #endregion

            clientMenu = new ClientMenu
            {
                Name     = model.Name,
                ParentId = model.ParentId,
                IncludeInSiteNavigation = model.IncludeInSiteNavigation,
                StartPublishingDate     = model.StartPublishingDate,
                EndPublishingDate       = model.EndPublishingDate,
                Url = string.IsNullOrWhiteSpace(model.Url) ? model.Name.ToUrlString() : model.Url.ToUrlString()
            };

            //Get menu record order
            relativeMenu = GetById(model.RelativeMenuId);
            if (relativeMenu != null)
            {
                if (model.Position == (int)ClientMenuEnums.PositionEnums.Before)
                {
                    clientMenu.RecordOrder = relativeMenu.RecordOrder - 1;
                }
                else
                {
                    clientMenu.RecordOrder = relativeMenu.RecordOrder + 1;
                }
            }

            response = HierarchyInsert(clientMenu);
            return(response.SetMessage(response.Success ?
                                       _localizedResourceServices.T("AdminModule:::ClientMenus:::Messages:::CreateSuccessfully:::Create client menu successfully.")
                : _localizedResourceServices.T("AdminModule:::ClientMenus:::Messages:::CreateFailure:::Create client menu failed. Please try again later.")));
        }