Ejemplo n.º 1
0
        public ActionResult SharedContent(BackEndSharedContentList backEndSharedContentList)
        {
            SharedContents sharedContents = new SharedContents();

            backEndSharedContentList.SharedContentList = sharedContents.GetSharedContents(backEndSharedContentList.SharedContentCode, backEndSharedContentList.IsActive);
            if (backEndSharedContentList.SharedContentList.IsNull() || backEndSharedContentList.SharedContentList.Count == 0)
            {
                ModelState.AddResult(ViewData, ModelStateResult.Error, Resources.Strings.NoDataFound);
            }

            return(View(backEndSharedContentList));
        }
Ejemplo n.º 2
0
        public ActionResult SharedContentAddEdit(string id)
        {
            BackEndSharedContentAddEdit backEndSharedContent = new BackEndSharedContentAddEdit();

            SharedContents sharedContents = new SharedContents();
            SharedContent  sharedContent;

            BackEndSharedContentLanguagesAddEdit backEndSharedContentLanguages;

            List <Language> allActiveLanguages = new Languages().GetAllLanguages(isActive: true);

            if (allActiveLanguages.IsNotNull() && allActiveLanguages.Count > 0)
            {
                if (id.IsNotEmptyOrWhiteSpace())
                {
                    List <SharedContent> backEndSharedContentList = sharedContents.GetSharedContents(id);
                    if (backEndSharedContentList.IsNotNull() && backEndSharedContentList.Count > 0)
                    {
                        backEndSharedContent.SharedContentCode    = id;
                        backEndSharedContent.NewSharedContentCode = id;
                        backEndSharedContent.IsActive             = backEndSharedContentList[0].IsActive;

                        foreach (Language language in allActiveLanguages)
                        {
                            backEndSharedContentLanguages = new BackEndSharedContentLanguagesAddEdit();
                            backEndSharedContentLanguages.LanguageCode = language.LanguageCode;
                            backEndSharedContentLanguages.LanguageName = language.LanguageName;

                            sharedContent = sharedContents.GetSharedContent(id, language.LanguageCode);
                            if (sharedContent.IsNotNull())
                            {
                                backEndSharedContentLanguages.HtmlCode = sharedContent.HtmlCode;
                            }

                            backEndSharedContent.SharedContentLanguages.Add(backEndSharedContentLanguages);
                        }
                    }
                    else
                    {
                        ModelState.AddResult(ViewData, ModelStateResult.Error, Resources.Strings.ItemDoesNotExist);
                        ViewData.IsFormVisible(false);
                    }
                }
                else
                {
                    foreach (Language language in allActiveLanguages)
                    {
                        backEndSharedContentLanguages = new BackEndSharedContentLanguagesAddEdit();
                        backEndSharedContentLanguages.LanguageCode = language.LanguageCode;
                        backEndSharedContentLanguages.LanguageName = language.LanguageName;

                        backEndSharedContent.SharedContentLanguages.Add(backEndSharedContentLanguages);
                    }
                }
            }
            else
            {
                ModelState.AddResult(ViewData, ModelStateResult.Error, Resources.Strings.UnexpectedError);
            }

            return(View(backEndSharedContent));
        }