public PageCreateModel PageCreate(PageCreateModel request) { PageCreateModel pageCreateModel = new PageCreateModel(); LanguageBusiness languageBusiness = new LanguageBusiness(); PageBusiness pageBusiness = new PageBusiness(); IEnumerable <Language> languageList = languageBusiness.LanguageList(); pageCreateModel.LanguageList = new SelectList(languageList, "ID", "Name", request.LanguageID); bool existLanguage = languageBusiness.ExistLanguage(request.LanguageID); if (!existLanguage) { pageCreateModel.Alerts.AlertList.Add("Dil bulunamadı!"); pageCreateModel.Alerts.AlertType = Model.Base.Alerts.AlertTypes.Error; return(pageCreateModel); } else { bool existSeoName = pageBusiness.ExistSeoName(request.SeoName); if (existSeoName) { pageCreateModel.Alerts.AlertList.Add("Seo adı daha önce kullanılmış!"); pageCreateModel.Alerts.AlertType = Model.Base.Alerts.AlertTypes.Error; return(pageCreateModel); } else { try { PageTranslation pageTranslation = pageBusiness.CreatePageTranslation(request.LanguageID, request.Name, request.SeoName, request.SeoKeyword, request.SeoDescription, request.Text, request.Picture); pageCreateModel.Alerts.AlertList.Add("Sayfa başarıyla eklendi"); pageCreateModel.RedirectURL = "/Management/Page/Index"; pageCreateModel.Alerts.AlertType = Model.Base.Alerts.AlertTypes.Success; } catch (Exception ex) { pageCreateModel.Alerts.AlertList.Add("Sayfa kaydedilemedi [ " + ex.Message + " ]"); pageCreateModel.Alerts.AlertType = Model.Base.Alerts.AlertTypes.Error; } } } return(pageCreateModel); }
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); }