예제 #1
0
 public ActionResult Create([ModelBinder(typeof(PageContentModelBinder))] PageContentModel pageContentModel)
 {
     if (ModelState.IsValid)
     {
         if (!IsAvailable(pageContentModel.PageUrl))
         {
             pageContentModel.PageUrl = CaseChange.TitleCase(pageContentModel.PageUrl);
             if (!pageContentModel.PageUrl.StartsWith("/"))
             {
                 pageContentModel.PageUrl = "/" + pageContentModel.PageUrl;
             }
             pageContentModel.PageName = CaseChange.TitleCase(pageContentModel.PageName);
             PageContent objPageContent = PageContentMap.Map(pageContentModel);
             _repPageContent.Add(objPageContent);
             _repPageContent.Save();
             TempData[LeonniConstants.SuccessMessage] = "Page Content added successfully";
             return(RedirectToAction("Index"));
         }
         else
         {
             TempData[LeonniConstants.ErrorMessage] = "\"" + pageContentModel.PageUrl + "\"" + " already exists, Please select another PageUrl name";
             return(RedirectToAction("Create"));
         }
     }
     else
     {
         LoadLanguageDropdown();
         return(View(pageContentModel));
     }
 }
예제 #2
0
        public ActionResult Edit(int id, [ModelBinder(typeof(PageContentModelBinder))] PageContentEditModel pageContentModel)
        {
            if (ModelState.IsValid)
            {
                PageContent objPageContent = _repPageContent.GetSingle(x => x.Id == id);
                if (objPageContent != null)
                {
                    pageContentModel.PageUrl  = CaseChange.TitleCase(pageContentModel.PageUrl);
                    pageContentModel.PageName = CaseChange.TitleCase(pageContentModel.PageName);
                    if (!pageContentModel.PageUrl.StartsWith("/"))
                    {
                        pageContentModel.PageUrl = "/" + pageContentModel.PageUrl;
                    }

                    PageContentMap.ApplyChanges(pageContentModel, objPageContent);

                    if (!string.IsNullOrWhiteSpace(objPageContent.Content))
                    {
                        _repPageContent.Update(objPageContent);
                        _repPageContent.Save();
                    }
                    else
                    {
                        //objPageContent.UpdateWithoutContent();
                    }
                }
                TempData[LeonniConstants.SuccessMessage] = "Page Content edited successfully";
                return(RedirectToAction("Index"));
            }
            else
            {
                LoadLanguageDropdown();
                return(View(pageContentModel));
            }
        }
예제 #3
0
        public ActionResult Create(LanguageModel languageModel)
        {
            try
            {
                if (!IsAvailable(languageModel.LanguageName))
                {
                    string strFileName      = string.Empty;
                    string strFileExtension = string.Empty;

                    foreach (string inputTagName in Request.Files)
                    {
                        HttpPostedFileBase file = Request.Files[inputTagName];
                        if (file.ContentLength == 0)
                        {
                            TempData[LeonniConstants.ErrorMessage] = "Please upload country flag";
                            return(RedirectToAction("Create"));
                        }

                        strFileExtension = Path.GetExtension(file.FileName);
                        strFileName      = languageModel.LanguageCode + strFileExtension;

                        if (strFileExtension.Equals(".png"))
                        {
                            string strTarget = Path.Combine(HttpContext.Server.MapPath(AppSettings.UploadFlagImage), strFileName);
                            file.SaveAs(strTarget);
                        }
                        else
                        {
                            TempData[LeonniConstants.ErrorMessage] = "\"" + strFileExtension + "\"" + " extension file is not supported, Please select '.png' extension file.";
                            return(RedirectToAction("Create"));
                        }
                    }

                    languageModel.LanguageName = CaseChange.TitleCase(languageModel.LanguageName);
                    objLanguage = LanguageMap.Map(languageModel);

                    _repLanguage.Add(objLanguage);
                    _repLanguage.Save();
                    TempData[LeonniConstants.SuccessMessage] = "Language is successfully created";
                    return(RedirectToAction("Index"));
                }
                else
                {
                    TempData[LeonniConstants.ErrorMessage] = "\"" + languageModel.LanguageName + "\"" + " already exists,Please select another Language Name";
                    return(RedirectToAction("Create"));
                }
            }
            catch
            {
                TempData[LeonniConstants.ErrorMessage] = "Some errors on Language Insertion";
                return(RedirectToAction("Create"));
            }
        }
예제 #4
0
        public ActionResult Edit(int id, LanguageModel languageModel)
        {
            try
            {
                languageModel.LanguageName = CaseChange.TitleCase(languageModel.LanguageName);
                objLanguage = LanguageMap.Map(languageModel);
                string strFileName      = string.Empty;
                string strFileExtension = string.Empty;

                foreach (string inputTagName in Request.Files)
                {
                    HttpPostedFileBase file = Request.Files[inputTagName];
                    if (file.ContentLength > 0)
                    {
                        strFileExtension = Path.GetExtension(file.FileName);
                        strFileName      = languageModel.LanguageCode + strFileExtension;

                        if (strFileExtension.Equals(".png"))
                        {
                            string strTarget = Path.Combine(HttpContext.Server.MapPath(AppSettings.UploadFlagImage), strFileName);
                            file.SaveAs(strTarget);
                        }
                        else
                        {
                            TempData[LeonniConstants.ErrorMessage] = "\"" + strFileExtension + "\"" + " extension file is not supported, Please select '.png' extension file.";
                            return(RedirectToAction("Create"));
                        }
                    }
                }

                _repLanguage.Update(objLanguage);
                _repLanguage.Save();
                TempData[LeonniConstants.SuccessMessage] = "Language is successfully updated";
                return(RedirectToAction("Index"));
            }
            catch
            {
                TempData[LeonniConstants.ErrorMessage] = "Some errors on Language Update";
                return(RedirectToAction("Edit"));
            }
        }