Beispiel #1
0
        public ActionResult Edit(PageEditModel request)
        {
            PageModelFactory pageModelFactory = new PageModelFactory();
            PageEditModel model = ModelState.IsValid ? pageModelFactory.EditPage(request) : pageModelFactory.LoadEdit(request.PageID, request.LanguageID);

            return CheckViewModel(model);
        }
Beispiel #2
0
        public PageEditModel EditPage(PageEditModel request)
        {
            PageEditModel pageEditModel = new PageEditModel();

            LanguageBusiness languageBusiness = new LanguageBusiness();
            PageBusiness pageBusiness = new PageBusiness();

            IEnumerable<Language> languageList = languageBusiness.LanguageList();

            pageEditModel.LanguageList = new SelectList(languageList, "ID", "Name", request.LanguageID);
            pageEditModel.PageID = request.PageID;

            bool existLanguage = languageBusiness.ExistLanguage(request.LanguageID);
            long? existPageTranslation = pageBusiness.ExistPageTranslationByPageIDAndLanguageID(request.PageID, request.LanguageID);

            if (!existLanguage)
            {
                pageEditModel.Alerts.AlertList.Add("Dil bulunamadı!");
                pageEditModel.Alerts.AlertType = Model.Base.Alerts.AlertTypes.Error;

                return request;
            }
            else
            {
                bool existSeoName = pageBusiness.ExistSeoName(request.SeoName,request.PageID);

                if (existSeoName)
                {
                    pageEditModel.Alerts.AlertList.Add("Seo adı daha önce kullanılmış!");
                    pageEditModel.Alerts.AlertType = Model.Base.Alerts.AlertTypes.Error;

                    return pageEditModel;
                }
                else
                {
                    try
                    {
                        if (!existPageTranslation.HasValue)
                        {
                            PageTranslation pageTranslation = pageBusiness.CreatePageTranslation(request.LanguageID, request.PageID, request.Name, request.SeoName, request.SeoKeyword, request.SeoDescription, request.Text, request.Picture);

                            pageEditModel.Alerts.AlertList.Add("Sayfa başarıyla eklendi");
                            pageEditModel.Alerts.AlertType = Model.Base.Alerts.AlertTypes.Success;
                        }
                        else
                        {
                            PageTranslation pageTranslation = pageBusiness.UpdatePageTranslation(request.LanguageID, request.PageID, request.Name, request.SeoName, request.SeoKeyword, request.SeoDescription, request.Text, request.Picture);

                            pageEditModel.Alerts.AlertList.Add("Sayfa başarıyla güncellendi.");
                            pageEditModel.Alerts.AlertType = Model.Base.Alerts.AlertTypes.Success;
                        }

                    }
                    catch (Exception ex)
                    {
                        request.Alerts.AlertList.Add("Sayfa kaydedilemedi [ " + ex.Message + " ]");
                        request.Alerts.AlertType = Model.Base.Alerts.AlertTypes.Error;
                    }
                }
            }

            return pageEditModel;
        }
Beispiel #3
0
        public PageEditModel LoadEdit(long pageID, long? languageID)
        {
            PageBusiness pageBusiness = new PageBusiness();
            LanguageBusiness languageBusiness = new LanguageBusiness();

            PageEditModel pageEditModel = new PageEditModel();

            Page page = pageBusiness.GetPage(pageID);
            PageTranslation pageTranslation = null;

            if (languageID.HasValue)
            {
                pageTranslation = page.PageTranslation.FirstOrDefault(z => z.LanguageID == languageID);
            }
            else
            {
                pageTranslation = page.PageTranslation.FirstOrDefault();
            }

            if (pageTranslation == null)
                pageTranslation = new PageTranslation();

            IEnumerable<Language> languageList = languageBusiness.LanguageList();

            pageEditModel.LanguageList = new SelectList(languageList, "ID", "Name", languageID);
            pageEditModel.LanguageID = pageTranslation.LanguageID;
            pageEditModel.Name = pageTranslation.Name;
            pageEditModel.PageID = page.ID;
            pageEditModel.Picture = pageTranslation.Picture;
            pageEditModel.SeoDescription = pageTranslation.SeoDescription;
            pageEditModel.SeoKeyword = pageTranslation.SeoKeyword;
            pageEditModel.SeoName = pageTranslation.SeoName;
            pageEditModel.Text = pageTranslation.Text;

            return pageEditModel;
        }