public ActionResult Index(string answer, int id) { string _answer = HttpUtility.UrlDecode(answer, System.Text.Encoding.Default); CustomMembershipDB db = new CustomMembershipDB(); var question = db.FAQ.SingleOrDefault(q => q.ID == id); if (question != null) { question.Answer = _answer; if (question.NotifyByEmail && !String.IsNullOrEmpty(question.NotifyEmail)) { var msgTitle = "dirot.somee.com. You got the answer on your question."; var msgBody = "Hello. You got the answer to the question that you asked in www.dirot.somee.com." + " Please follow the <a href='www.dirot.somee.com/FAQ' target='_blank'>link</a> to see the answer."; UserRepository.SendEmailThroughGmail(msgTitle, msgBody, question.NotifyEmail); question.NotifyByEmail = false; } db.SaveChanges(); } else { //add error } //return Json(answer, "text/html"); return(Content(_answer, "text/html")); }
public ActionResult GalleryPagesAddNew(int id) { if (id == -1) //new page { return(View(new GalleryPages())); } var db = new CustomMembershipDB(); var editPage = db.GalleryPages.FirstOrDefault(p => p.Id == id); if (editPage == null) { return(View(new GalleryPages())); } return(View(editPage)); //var editPages = db.GalleryPages.Where(p => p.Id == id); //if (editPages.Count() == 0) // return View(new GalleryPages()); //return View(editPages.ToList()); //var qwer11list = new List<qwer11>(); //qwer11list.Add(new qwer11() //{ // alt = "alt1", // date = DateTime.Now, // name = "nameq" //}); //qwer11list.Add(new qwer11() //{ // alt = "alt2", // date = DateTime.Now, // name = "nameq" //}); //return View(qwer11list); }
public PartialViewResult Edit(FormCollection formCollection) { var userID = int.Parse(formCollection["item.UserId"]); var db = new CustomMembershipDB(); var user = db.Users.SingleOrDefault(u => u.UserId == userID); if(user != null) { user.UserName = String.IsNullOrEmpty(formCollection["item.UserName"]) ? user.UserName : formCollection["item.UserName"]; user.Email = String.IsNullOrEmpty(formCollection["item.Email"]) ? user.Email : formCollection["item.Email"]; DateTime createdDate = user.CreatedDate; if (DateTime.TryParseExact(formCollection["item.CreatedDate"], "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out createdDate)) user.CreatedDate = createdDate; user.IsActivated = String.IsNullOrEmpty(formCollection["item.IsActivated"]) ? user.IsActivated : formCollection["item.IsActivated"].Any(act => act == 't'); user.IsLockedOut = String.IsNullOrEmpty(formCollection["item.IsLockedOut"]) ? user.IsLockedOut : formCollection["item.IsLockedOut"].Any(loc => loc == 't'); user.LastLockedOutReason = formCollection["item.LastLockedOutReason"] == null ? user.LastLockedOutReason : formCollection["item.LastLockedOutReason"]; DateTime lastLockedOutDate = user.LastLockedOutDate; if (DateTime.TryParseExact(formCollection["item.LastLockedOutDate"], "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out lastLockedOutDate)) user.LastLockedOutDate = lastLockedOutDate; if (!formCollection["item.RoleName"].Equals("0") && !user.Roles.Any(r => r.RoleName == formCollection["item.RoleName"])) { var RoleService = new AccountRoleService(); RoleService.AddUsersToRoles(new string[] { user.UserName }, new string[] { formCollection["item.RoleName"] }); } db.SaveChanges(); } return PartialView("_UserPartial", ModelsHelper.GetUserFromTable(user)); // return PartialView("_UserPartial", new TaskTimer.Areas.Admin.Models.User()); }
// // GET: /Admin/ //[Authorize(Roles = "Admin")] public ActionResult Index() { var db = new CustomMembershipDB(); List<SelectListItem> sl = new SelectList((IEnumerable<Roles>)db.Roles, "RoleName", "RoleName").ToList(); sl.Insert(0, new SelectListItem { Text = "---", Value = "0" }); ViewBag.Roles = sl; return View(ModelsHelper.GetAllUsersTable()); }
public void AddNewPage(SiteMainPages newPage) { var db = new CustomMembershipDB(); db.SiteMainPages.Add(newPage); //db.SaveChanges(); var file = Request.Form["TitleImage"]; //RedirectToAction("Index", "AdminController"); //return PartialView("_PagesPartial", db.SiteMainPages); }
public PartialViewResult Users() { var db = new CustomMembershipDB(); List<SelectListItem> sl = new SelectList((IEnumerable<Roles>)db.Roles, "RoleName", "RoleName").ToList(); sl.Insert(0, new SelectListItem { Text = "---", Value = "0" }); ViewBag.Roles = sl; return PartialView("_UsersPartial", ModelsHelper.GetAllUsersTable()); //return PartialView("_UsersPartial", db.Users); }
public ActionResult Index(int?page) { ViewBag.Message = "Questions list."; CustomMembershipDB db = new CustomMembershipDB(); var listCustomer = db.FAQ.Where(f => f.Active == true).OrderByDescending(i => i.ID).ToList(); int pageSize = 5; int pageNumber = (page ?? 1); return(View(listCustomer.ToPagedList(pageNumber, pageSize))); }
public PartialViewResult GalleryImages(int id) { //if (id == -1) // return PartialView("_ImagesPartial", new GalleryImages()); CustomMembershipDB db = new CustomMembershipDB(); var galleryImages = db.GalleryPages.FirstOrDefault(p => p.Id == id); return(PartialView("_GalleryImagesPartial", galleryImages.GalleryImages.ToList())); }
// // GET: /Gallery/ public ActionResult Index(int id) { var db = new CustomMembershipDB(); var page = db.GalleryPages.FirstOrDefault(g => g.Id == id); if (page == null) { page = new GalleryPages(); } return(View(page)); }
public static List <User> GetAllUsersTable() { var users = new List <User>(); var db = new CustomMembershipDB(); foreach (var user in db.Users) { users.Add(GetUserFromTable(user)); } return(users); }
// // GET: /SitePages/ public ActionResult Index(int id) { var db = new CustomMembershipDB(); var page = db.SiteMainPages.FirstOrDefault(p => p.Id == id); if (page == null) { page = new SiteMainPages(); } return(View(page)); }
public ActionResult PagesAddNew(MmgtaaboraPages newPage) { if (ModelState.IsValid) { var db = new CustomMembershipDB(); var newSavedPage = db.MmgtaaboraPages.Add(newPage); db.SaveChanges(); return(RedirectToAction("PagesEdit", new { id = newSavedPage.Id })); } return(View()); }
public ActionResult EfarganPagesDelete(EfarganPages curPage, int id) { var db = new CustomMembershipDB(); var pageToDelete = db.EfarganPages.FirstOrDefault(p => p.Id == id); if (pageToDelete != null) { db.EfarganPages.Remove(pageToDelete); // db.SaveChanges(); } return(RedirectToAction("EfarganPages")); }
public ActionResult SitePagesDelete(int id) { var db = new CustomMembershipDB(); var deletePage = db.SiteMainPages.FirstOrDefault(p => p.Id == id); if (deletePage != null) { db.SiteMainPages.Remove(deletePage); db.SaveChanges(); } return(RedirectToAction("SitePages")); }
public static List <SelectListItem> GetEfarganLanguageSelectListItem(int id) { var db = new CustomMembershipDB(); return(db.EfarganLanguage.Select( lng => new SelectListItem { Text = lng.LanguageName, Value = lng.LanguageValue, Selected = id == lng.Id }).ToList());; }
public ActionResult Delete(int id) { CustomMembershipDB db = new CustomMembershipDB(); var question = db.FAQ.SingleOrDefault(q => q.ID == id); if (question != null) { question.Active = false; db.SaveChanges(); } return(Content("")); }
public ActionResult GalleryPagesDeleteAjax(int id) { CustomMembershipDB db = new CustomMembershipDB(); var galleryPage = db.GalleryPages.SingleOrDefault(q => q.Id == id); if (galleryPage != null) { db.GalleryPages.Remove(galleryPage); //db.SaveChanges(); return(Content("OK")); } return(Content("Page was not found")); }
public ActionResult SitePagesAddNew(int id) { if (id == -1) //new page { return(View(new SiteMainPages())); } var db = new CustomMembershipDB(); var editPage = db.SiteMainPages.FirstOrDefault(p => p.Id == id); if (editPage == null) { editPage = new SiteMainPages(); } return(View(editPage)); }
public PartialViewResult Delete(string id) { var userID = int.Parse(id); var db = new CustomMembershipDB(); var user = db.Users.SingleOrDefault(u => u.UserId == userID); if (user != null) { db.Users.Remove(user); //db.SaveChanges(); } List<SelectListItem> sl = new SelectList((IEnumerable<Roles>)db.Roles, "RoleName", "RoleName").ToList(); sl.Insert(0, new SelectListItem { Text = "---", Value = "0" }); ViewBag.Roles = sl; return PartialView("_UsersPartial", ModelsHelper.GetAllUsersTable()); }
// // GET: /Efargan.co.il/Pages/ public ActionResult Index(int?id, string lng) { ViewBag.PageLng = lng; var db = new CustomMembershipDB(); var viewPage = new EfarganPages(); if (id == null) { id = 0; } if (lng.Equals("HE")) { viewPage = db.EfarganPages.SingleOrDefault(p => p.Id == id); if (viewPage == null) { viewPage = db.EfarganPages.FirstOrDefault(p => p.Id == 0); } ViewBag.SearchBtn = "חיפוש"; } else //get page in different language { ViewBag.SearchBtn = "Search"; viewPage = db.EfarganPages.SingleOrDefault(p => p.Id == id); if (viewPage == null) { viewPage = db.EfarganPages.FirstOrDefault(p => p.Id == 0); } var curLngPage = viewPage.EfarganPagesLanguage.FirstOrDefault(pl => pl.EfarganLanguage.LanguageValue == lng); if (curLngPage != null) { viewPage = new EfarganPages() { MetaTag = curLngPage.MetaTag, TitleTag = curLngPage.TitleTag, DescriptionTag = curLngPage.DescriptionTag, TicketTitle = curLngPage.TicketTitle, TicketLinkText = curLngPage.TicketLinkText, TicketLinkURL = curLngPage.TicketLinkURL, EfarganPagesSliders = curLngPage.EfarganPagesSliders, EfarganPagesParagraphs = curLngPage.EfarganPagesParagraphs, EfarganPagesTickers = curLngPage.EfarganPagesTickers }; } } return(View(viewPage)); }
public ActionResult EfarganPagesSaveSlider(EfarganPages curPage, int id) { if (ModelState.IsValid) { var db = new CustomMembershipDB(); var curPage2 = db.EfarganPages.SingleOrDefault(ef => ef.Id == id); if (curPage2 == null) { //db.EfarganPages.Add(curPage); return(RedirectToAction("EfarganPages")); } else { foreach (var slider in curPage.EfarganPagesSliders) { var sliderToUpdate = curPage2.EfarganPagesSliders.FirstOrDefault(sl => sl.Id == slider.Id); if (sliderToUpdate != null) { sliderToUpdate.SliderTitle = slider.SliderTitle; sliderToUpdate.SliderText = slider.SliderText; sliderToUpdate.SliderLinkText = slider.SliderLinkText; sliderToUpdate.SliderLinkURL = slider.SliderLinkURL; sliderToUpdate.SliderImageFileName = slider.SliderImageFileName; } else if (slider.Id == -1 && ( !string.IsNullOrEmpty(slider.SliderTitle) || !string.IsNullOrEmpty(slider.SliderText) || !string.IsNullOrEmpty(slider.SliderLinkText) || !string.IsNullOrEmpty(slider.SliderLinkURL) || !string.IsNullOrEmpty(slider.SliderImageFileName) )) //add new slider to list { curPage2.EfarganPagesSliders.Add(slider); } } } db.Entry(curPage2).State = EntityState.Modified; db.SaveChanges(); ModelState.Clear(); return(View(curPage2)); } //var qwer1 = Request.Form["EfarganPagesSliders[0].SliderText"].ToString(); return(RedirectToAction("EfarganPages")); }
public ActionResult DeletePermanently(int id) { CustomMembershipDB db = new CustomMembershipDB(); var question = db.FAQ.SingleOrDefault(q => q.ID == id); if (question != null) { var images = question.Images.ToList(); for (int i = 0; i < images.Count; i++) { Helper.RemoveFile(dirName, images[i].Name); // remove image from server db.Images.Remove(images[i]); // remove image from db } db.FAQ.Remove(question); db.SaveChanges(); } return(Content("")); }
void Session_Start(object sender, EventArgs e) { // Code that runs when a new session is started Session["start"] = DateTime.Now; Application.Lock(); Application["onlinevisitors"] = Convert.ToInt32(Application["onlinevisitors"]) + 1; Application.UnLock(); // get total visits var appID = Guid.Parse(ConfigurationManager.AppSettings["ApplicationId"]); using (var db = new CustomMembershipDB()) { var curApp = db.Applications.FirstOrDefault(app => app.ApplicationId == appID); if (curApp != null) { curApp.UserCounter++; db.SaveChanges(); Application["totalvisitors"] = curApp.UserCounter; Application["totalusers"] = db.Users.Count(); } } }
public ActionResult SitePagesAddNew(SiteMainPages newPage) { //upload files var saveToDirectory = AppDomain.CurrentDomain.BaseDirectory + "Images\\Site Pages\\"; foreach (string file in Request.Files) { HttpPostedFileBase hpf = Request.Files[file] as HttpPostedFileBase; if (hpf.ContentLength == 0) { continue; } var saveFileName = Path.GetFileName(hpf.FileName); saveFileName = AdminHelper.GetUniqueFileName(saveToDirectory, saveFileName); string savedFileName = Path.Combine( saveToDirectory, saveFileName); hpf.SaveAs(savedFileName); if (file.Equals("TitleImage")) { newPage.TitleImage = saveFileName; } else if (file.Equals("BodyImage")) { newPage.BodyImage = saveFileName; } else if (file.Equals("FooterImage")) { newPage.FooterImage = saveFileName; } } var db = new CustomMembershipDB(); db.SiteMainPages.Add(newPage); db.SaveChanges(); return(RedirectToAction("SitePages")); }
public ActionResult _MainMenu(string lng) { //var lng = (string)ViewBag.PageLng; var db = new CustomMembershipDB(); Dictionary <int, string> dictionary = new Dictionary <int, string>(); if (lng.Equals("HE")) { dictionary = db.EfarganPages.ToDictionary(p => p.Id, p => p.MenuText); } else { //get all pages in different language var curLng = db.EfarganLanguage.FirstOrDefault(l => l.LanguageValue == lng); if (curLng != null) { var pagesLng = db.EfarganPagesLanguage.Where(pl => pl.EfarganLanguage.Id == curLng.Id); if (pagesLng.Count() > 0) { dictionary = pagesLng.ToDictionary(p => p.Id, p => p.MenuText); } } } return(PartialView("_MainMenu", dictionary)); }
public ActionResult AddNew(FAQModel model) { if (ModelState.IsValid) { try { //prepere question var question = HttpUtility.UrlDecode(model.Question, System.Text.Encoding.Default); question = question.Replace("/Temporary", ""); //new file location model.ImageNames = model.ImageNames[0].Split(','); //add new FAQ to db int? QUserId = null; string NotifyEmail = model.NotifyEmail; CustomMembershipDB db = new CustomMembershipDB(); var curUserId = db.Users.SingleOrDefault(u => u.UserName.Equals(User.Identity.Name)); if (curUserId != null) { QUserId = curUserId.UserId; NotifyEmail = String.IsNullOrEmpty(model.NotifyEmail) ? curUserId.Email : model.NotifyEmail; } var newFAQ = new FAQ { QUserId = QUserId, Date = DateTime.Now, Title = model.Title, Question = question, NotifyByEmail = model.NotifyByEmail, NotifyEmail = NotifyEmail, Active = true }; db.FAQ.Add(newFAQ); //check if all uploaded images appear in question Helper.CheckQuestionImages(dirName, question, model.ImageNames); //add images data foreach (var imageName in model.ImageNames) { db.Images.Add(new Images { FAQ = newFAQ, Name = imageName }); } db.SaveChanges(); //work with files Helper.MoveFiles(dirName, model.ImageNames); ViewBag.AddQuestionStatus = "Question added."; return(RedirectToAction("Index")); } catch (Exception) { ModelState.AddModelError("", "There was an error during save of question."); return(View()); } } else { return(View()); } }
public ActionResult EfarganPagesLanguageEdit(EfarganPages curPage, int id, string itemType, int itemCount) { var db = new CustomMembershipDB(); var curPage2 = db.EfarganPagesLanguage.SingleOrDefault(efl => efl.Id == id); if (curPage2 == null) { //db.EfarganPages.Add(curPage); return(RedirectToAction("EfarganPages")); } else { for (int i = 0; i < itemCount; i++) { switch (itemType) { case "Sliders": //get slider data var SliderId = int.Parse(Request.Form["EfarganPagesLanguage.item.EfarganPagesSliders[" + i + "].Id"]); var SliderTitle = Request.Form["EfarganPagesLanguage.item.EfarganPagesSliders[" + i + "].SliderTitle"]; var SliderText = Request.Form["EfarganPagesLanguage.item.EfarganPagesSliders[" + i + "].SliderText"]; var SliderLinkText = Request.Form["EfarganPagesLanguage.item.EfarganPagesSliders[" + i + "].SliderLinkText"]; var SliderLinkURL = Request.Form["EfarganPagesLanguage.item.EfarganPagesSliders[" + i + "].SliderLinkURL"]; var SliderImageFileName = Request.Form["EfarganPagesLanguage.item.EfarganPagesSliders[" + i + "].SliderImageFileName"]; var SliderImageURL = Request.Form["EfarganPagesLanguage.item.EfarganPagesSliders[" + i + "].SliderImageURL"]; //get file data var file = Request.Files["SliderImage_" + SliderId]; var savedFileName = ""; if (file != null && file.ContentLength > 0) //need to save a new file { //delete old file if file already exist if (!string.IsNullOrEmpty(SliderImageFileName) && !string.IsNullOrEmpty(SliderImageURL)) { var oldFileName = SliderImageURL.Split('/').Last(); var savedToDirectory = AppDomain.CurrentDomain.BaseDirectory + AdminEfarganHelper.PageImagesPath; var savedOldFilePath = savedToDirectory + "/" + oldFileName; System.IO.File.Delete(savedOldFilePath); } savedFileName = AdminEfarganHelper.SavePageImage(file); } //add / update slider data if (!string.IsNullOrEmpty(SliderTitle) || !string.IsNullOrEmpty(SliderText) || !string.IsNullOrEmpty(SliderLinkText) || !string.IsNullOrEmpty(SliderLinkURL)) { EfarganPagesSliders curSlider; if (SliderId == -1) { curSlider = new EfarganPagesSliders(); curPage2.EfarganPagesSliders.Add(curSlider); } else { curSlider = curPage2.EfarganPagesSliders.FirstOrDefault(s => s.Id == SliderId); } curSlider.SliderTitle = SliderTitle; curSlider.SliderText = SliderText; curSlider.SliderLinkText = SliderLinkText; curSlider.SliderLinkURL = SliderLinkURL; if (file != null && file.ContentLength > 0) //need to save a new file { curSlider.SliderImageURL = AdminEfarganHelper.PageImagesPath + savedFileName.Split('/').Last(); curSlider.SliderImageFileName = file.FileName; } } break; case "Paragraphs": //get paragraph data var ParagraphId = int.Parse(Request.Form["EfarganPagesLanguage.item.EfarganPagesParagraphs[" + i + "].Id"]); var ParagraphTitle = Request.Form["EfarganPagesLanguage.item.EfarganPagesParagraphs[" + i + "].ParagraphTitle"]; var ParagraphText = Request.Form["EfarganPagesLanguage.item.EfarganPagesParagraphs[" + i + "].ParagraphText"]; var ParagraphLinkText = Request.Form["EfarganPagesLanguage.item.EfarganPagesParagraphs[" + i + "].ParagraphLinkText"]; var ParagraphLinkURL = Request.Form["EfarganPagesLanguage.item.EfarganPagesParagraphs[" + i + "].ParagraphLinkURL"]; var ParagraphImageFileName = Request.Form["EfarganPagesLanguage.item.EfarganPagesParagraphs[" + i + "].ParagraphImageFileName"]; var ParagraphImageURL = Request.Form["EfarganPagesLanguage.item.EfarganPagesParagraphs[" + i + "].ParagraphImageURL"]; //get file data var file2 = Request.Files["ParagraphImage_" + ParagraphId]; var savedFileName2 = ""; if (file2 != null && file2.ContentLength > 0) //need to save a new file { //delete old file if file already exist if (!string.IsNullOrEmpty(ParagraphImageFileName) && !string.IsNullOrEmpty(ParagraphImageURL)) { var oldFileName = ParagraphImageURL.Split('/').Last(); var savedToDirectory = AppDomain.CurrentDomain.BaseDirectory + AdminEfarganHelper.PageImagesPath; var savedOldFilePath = savedToDirectory + "/" + oldFileName; System.IO.File.Delete(savedOldFilePath); } savedFileName2 = AdminEfarganHelper.SavePageImage(file2); } if (!string.IsNullOrEmpty(ParagraphTitle) || !string.IsNullOrEmpty(ParagraphText) || !string.IsNullOrEmpty(ParagraphLinkText) || !string.IsNullOrEmpty(ParagraphLinkURL)) { EfarganPagesParagraphs curParagraph; if (ParagraphId == -1) { curParagraph = new EfarganPagesParagraphs(); curPage2.EfarganPagesParagraphs.Add(curParagraph); } else { curParagraph = curPage2.EfarganPagesParagraphs.FirstOrDefault(p => p.Id == ParagraphId); } curParagraph.ParagraphTitle = ParagraphTitle; curParagraph.ParagraphText = ParagraphText; curParagraph.ParagraphLinkText = ParagraphLinkText; curParagraph.ParagraphLinkURL = ParagraphLinkURL; if (file2 != null && file2.ContentLength > 0) //need to save a new file { curParagraph.ParagraphImageURL = AdminEfarganHelper.PageImagesPath + savedFileName2.Split('/').Last(); curParagraph.ParagraphImageFileName = file2.FileName; } } break; case "Tickers": var TickerId = int.Parse(Request.Form["EfarganPagesLanguage.item.EfarganPagesTickers[" + i + "].Id"]); var TickerTitle = Request.Form["EfarganPagesLanguage.item.EfarganPagesTickers[" + i + "].TickerTitle"]; var TickerText = Request.Form["EfarganPagesLanguage.item.EfarganPagesTickers[" + i + "].TickerText"]; var TickerLinkText = Request.Form["EfarganPagesLanguage.item.EfarganPagesTickers[" + i + "].TickerLinkText"]; var TickerLinkURL = Request.Form["EfarganPagesLanguage.item.EfarganPagesTickers[" + i + "].TickerLinkURL"]; if (!string.IsNullOrEmpty(TickerTitle) || !string.IsNullOrEmpty(TickerText) || !string.IsNullOrEmpty(TickerLinkText) || !string.IsNullOrEmpty(TickerLinkURL)) { EfarganPagesTickers curTicker; if (TickerId == -1) { curTicker = new EfarganPagesTickers(); curPage2.EfarganPagesTickers.Add(curTicker); } else { curTicker = curPage2.EfarganPagesTickers.FirstOrDefault(p => p.Id == TickerId); } curTicker.TickerTitle = TickerTitle; curTicker.TickerText = TickerText; curTicker.TickerLinkText = TickerLinkText; curTicker.TickerLinkURL = TickerLinkURL; } break; default: break; } } } db.Entry(curPage2).State = EntityState.Modified; db.SaveChanges(); ModelState.Clear(); return(RedirectToAction("EfarganPagesEdit", new { curPage = curPage, id = curPage2.EfarganPages.Id })); }
public ActionResult EfarganPagesEdit(EfarganPages curPage, int id) { if (ModelState.IsValid) { var db = new CustomMembershipDB(); var curPage2 = db.EfarganPages.SingleOrDefault(ef => ef.Id == id); if (curPage2 == null) { //db.EfarganPages.Add(curPage); return(RedirectToAction("EfarganPages")); } else { //update page data if (curPage.EfarganPagesParagraphs.Count == 0 && curPage.EfarganPagesSliders.Count == 0 && curPage.EfarganPagesTickers.Count == 0) { curPage2.TitleTag = curPage.TitleTag; curPage2.MetaTag = curPage.MetaTag; curPage2.DescriptionTag = curPage.DescriptionTag; curPage2.MenuText = curPage.MenuText; curPage2.TicketTitle = curPage.TicketTitle; curPage2.TicketLinkText = curPage.TicketLinkText; curPage2.TicketLinkURL = curPage.TicketLinkURL; } //update / add to sliders if (curPage.EfarganPagesSliders.Count > 0) { foreach (var slider in curPage.EfarganPagesSliders) { //get file data var file = Request.Files["SliderImage_" + slider.Id]; var savedFileName = ""; if (file != null && file.ContentLength > 0) //need to save a new file { //delete old file if file already exist if (slider.SliderImageURL != null && !string.IsNullOrEmpty(slider.SliderImageURL) && slider.SliderImageFileName != null && !string.IsNullOrEmpty(slider.SliderImageFileName)) { var oldFileName = slider.SliderImageURL.Split('/').Last(); var savedToDirectory = AppDomain.CurrentDomain.BaseDirectory + AdminEfarganHelper.PageImagesPath; var savedOldFilePath = savedToDirectory + "/" + oldFileName; System.IO.File.Delete(savedOldFilePath); } savedFileName = AdminEfarganHelper.SavePageImage(file); } //add / update slider data var sliderToUpdate = curPage2.EfarganPagesSliders.FirstOrDefault(sl => sl.Id == slider.Id); if (sliderToUpdate != null) { sliderToUpdate.SliderTitle = slider.SliderTitle; sliderToUpdate.SliderText = slider.SliderText; sliderToUpdate.SliderLinkText = slider.SliderLinkText; sliderToUpdate.SliderLinkURL = slider.SliderLinkURL; if (file != null && file.ContentLength > 0) //need to save a new file { sliderToUpdate.SliderImageURL = AdminEfarganHelper.PageImagesPath + savedFileName.Split('/').Last(); sliderToUpdate.SliderImageFileName = file.FileName; } } else if (slider.Id == -1 && ( !string.IsNullOrEmpty(slider.SliderTitle) || !string.IsNullOrEmpty(slider.SliderText) || !string.IsNullOrEmpty(slider.SliderLinkText) || !string.IsNullOrEmpty(slider.SliderLinkURL) || !string.IsNullOrEmpty(slider.SliderImageFileName) )) //add new slider to list { if (file != null && file.ContentLength > 0) //need to save a new file { slider.SliderImageURL = AdminEfarganHelper.PageImagesPath + savedFileName.Split('/').Last(); slider.SliderImageFileName = file.FileName; } curPage2.EfarganPagesSliders.Add(slider); } } } //update / add to paragraphs if (curPage.EfarganPagesParagraphs.Count > 0) { foreach (var paragraph in curPage.EfarganPagesParagraphs) { //get file data var file = Request.Files["ParagraphImage_" + paragraph.Id]; var savedFileName = ""; if (file != null && file.ContentLength > 0) //need to save a new file { //delete old file if file already exist if (paragraph.ParagraphImageURL != null && !string.IsNullOrEmpty(paragraph.ParagraphImageURL) && paragraph.ParagraphImageFileName != null && !string.IsNullOrEmpty(paragraph.ParagraphImageFileName)) { var oldFileName = paragraph.ParagraphImageURL.Split('/').Last(); var savedToDirectory = AppDomain.CurrentDomain.BaseDirectory + AdminEfarganHelper.PageImagesPath; var savedOldFilePath = savedToDirectory + "/" + oldFileName; System.IO.File.Delete(savedOldFilePath); } savedFileName = AdminEfarganHelper.SavePageImage(file); } //add / update paragraph data var paragraphToUpdate = curPage2.EfarganPagesParagraphs.FirstOrDefault(sl => sl.Id == paragraph.Id); if (paragraphToUpdate != null) { paragraphToUpdate.ParagraphTitle = paragraph.ParagraphTitle; paragraphToUpdate.ParagraphText = paragraph.ParagraphText; paragraphToUpdate.ParagraphLinkText = paragraph.ParagraphLinkText; paragraphToUpdate.ParagraphLinkURL = paragraph.ParagraphLinkURL; paragraphToUpdate.ParagraphImageFileName = paragraph.ParagraphImageFileName; if (file != null && file.ContentLength > 0) //need to save a new file { paragraphToUpdate.ParagraphImageURL = AdminEfarganHelper.PageImagesPath + savedFileName.Split('/').Last(); paragraphToUpdate.ParagraphImageFileName = file.FileName; } } else if (paragraph.Id == -1 && ( !string.IsNullOrEmpty(paragraph.ParagraphTitle) || !string.IsNullOrEmpty(paragraph.ParagraphText) || !string.IsNullOrEmpty(paragraph.ParagraphLinkText) || !string.IsNullOrEmpty(paragraph.ParagraphLinkURL) || !string.IsNullOrEmpty(paragraph.ParagraphImageFileName) )) //add new slider to list { if (file != null && file.ContentLength > 0) //need to save a new file { paragraph.ParagraphImageURL = AdminEfarganHelper.PageImagesPath + savedFileName.Split('/').Last(); paragraph.ParagraphImageFileName = file.FileName; } curPage2.EfarganPagesParagraphs.Add(paragraph); } } } //update / add to tickets if (curPage.EfarganPagesTickers.Count > 0) { foreach (var ticker in curPage.EfarganPagesTickers) { var tickerToUpdate = curPage2.EfarganPagesTickers.FirstOrDefault(sl => sl.Id == ticker.Id); if (tickerToUpdate != null) { tickerToUpdate.TickerTitle = ticker.TickerTitle; tickerToUpdate.TickerText = ticker.TickerText; tickerToUpdate.TickerLinkText = ticker.TickerLinkText; tickerToUpdate.TickerLinkURL = ticker.TickerLinkURL; } else if (ticker.Id == -1 && ( !string.IsNullOrEmpty(ticker.TickerTitle) || !string.IsNullOrEmpty(ticker.TickerText) || !string.IsNullOrEmpty(ticker.TickerLinkText) || !string.IsNullOrEmpty(ticker.TickerLinkURL) )) //add new slider to list { curPage2.EfarganPagesTickers.Add(ticker); } } } //update / add to page language if (curPage.EfarganPagesLanguage.Count > 0) { int i = 0; foreach (var pagesLanguage in curPage.EfarganPagesLanguage) { var pagesLanguageToUpdate = curPage2.EfarganPagesLanguage.FirstOrDefault(lng => lng.Id == pagesLanguage.Id); if (pagesLanguageToUpdate != null) { pagesLanguageToUpdate.TitleTag = pagesLanguage.TitleTag; pagesLanguageToUpdate.MetaTag = pagesLanguage.MetaTag; pagesLanguageToUpdate.DescriptionTag = pagesLanguage.DescriptionTag; pagesLanguageToUpdate.MenuText = pagesLanguage.MenuText; pagesLanguageToUpdate.TicketTitle = pagesLanguage.TicketTitle; pagesLanguageToUpdate.TicketLinkText = pagesLanguage.TicketLinkText; pagesLanguageToUpdate.TicketLinkURL = pagesLanguage.TicketLinkURL; pagesLanguageToUpdate.EfarganLanguage = pagesLanguage.EfarganLanguage; //get page language var LanguageValue = Request.Form["EfarganPagesLanguage[" + i + "].SiteLanguages"]; var curLang = db.EfarganLanguage.FirstOrDefault(lng => lng.LanguageValue == LanguageValue); if (curLang != null) { pagesLanguageToUpdate.EfarganLanguage = curLang; } i++; } else if (pagesLanguage.Id == -1 && ( !string.IsNullOrEmpty(pagesLanguage.TitleTag) || !string.IsNullOrEmpty(pagesLanguage.MetaTag) || !string.IsNullOrEmpty(pagesLanguage.DescriptionTag) || !string.IsNullOrEmpty(pagesLanguage.MenuText) || !string.IsNullOrEmpty(pagesLanguage.TicketTitle) || !string.IsNullOrEmpty(pagesLanguage.TicketLinkText) || !string.IsNullOrEmpty(pagesLanguage.TicketLinkURL) )) //add new slider to list { //get page language var LanguageValue = Request.Form["EfarganPagesLanguage[" + i + "].SiteLanguages"]; var curLang = db.EfarganLanguage.FirstOrDefault(lng => lng.LanguageValue == LanguageValue); if (curLang != null) { pagesLanguage.EfarganLanguageRef = curLang.Id; } curPage2.EfarganPagesLanguage.Add(pagesLanguage); i++; } } } } db.Entry(curPage2).State = EntityState.Modified; db.SaveChanges(); ModelState.Clear(); return(View(curPage2)); } return(RedirectToAction("EfarganPages")); }
public ActionResult SiteSearch(string key, string lng) { CustomMembershipDB db = new CustomMembershipDB(); // search in DB //if (lng.Equals("HE")) //{ var searchResultsSliders = db.EfarganPagesSliders.Where(pr => pr.SliderText.Contains(key) || pr.SliderTitle.Contains(key) || pr.SliderLinkText.Contains(key)); var searchResultsParagraphs = db.EfarganPagesParagraphs.Where(pr => pr.ParagraphText.Contains(key) || pr.ParagraphTitle.Contains(key) || pr.ParagraphLinkText.Contains(key)); var searchResultsTickers = db.EfarganPagesTickers.Where(pr => pr.TickerText.Contains(key) || pr.TickerTitle.Contains(key) || pr.TickerLinkText.Contains(key)); //} //else //search in different language //{ // var searchResultsSliders = db.EfarganPagesSliders.Where(pr => pr.SliderText.Contains(key) // || pr.SliderTitle.Contains(key) // || pr.SliderLinkText.Contains(key)); // var searchResultsParagraphs = db.EfarganPagesParagraphs.Where(pr => pr.ParagraphText.Contains(key) // || pr.ParagraphTitle.Contains(key) // || pr.ParagraphLinkText.Contains(key)); // var searchResultsTickers = db.EfarganPagesTickers.Where(pr => pr.TickerText.Contains(key) // || pr.TickerTitle.Contains(key) // || pr.TickerLinkText.Contains(key)); //} //get output var responseHtml = ""; switch (lng) { case "HE": responseHtml += "<b>תוצאות החיפוש</b>"; if (searchResultsSliders.Count() == 0 && searchResultsParagraphs.Count() == 0) { responseHtml += "<b>לא נמצאו תוצאות עבור '" + key + "'</b>"; } break; case "ENG": responseHtml += "<b>Search results</b>"; if (searchResultsSliders.Count() == 0 && searchResultsParagraphs.Count() == 0) { responseHtml += "<b>No results found for '" + key + "'</b>"; } break; case "RU": responseHtml += "<b>Результат поиска</b>"; if (searchResultsSliders.Count() == 0 && searchResultsParagraphs.Count() == 0) { responseHtml += "<b>Нечего небыло найдено для '" + key + "'</b>"; } break; default: responseHtml += "<b>תוצאות החיפוש</b>"; break; } var keyArr = new string[1] { key }; var keyDistinguished = "<span class='searchResponseDistinguished'>" + key + "</span>"; foreach (var item in searchResultsSliders) { responseHtml += "<div class='searchResponse'>"; responseHtml += "<div class='searchResponseTitle'>"; var responseTitle = item.SliderTitle; if (item.SliderTitle.Contains(key)) { var responseTitleArr = responseTitle.Split(key.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); responseTitle = responseTitleArr[0] + key + responseTitleArr[1]; } responseHtml += responseTitle; responseHtml += "</div>"; //item.SliderText responseHtml += "</div>"; } foreach (var item in searchResultsParagraphs) { responseHtml += "<div class='searchResponse'>"; //title responseHtml += "<div class='searchResponseTitle'>"; var responseTmp = item.ParagraphTitle; if (item.ParagraphTitle != null && item.ParagraphTitle.Contains(key)) { var responseTitleArr = responseTmp.Split(keyArr, StringSplitOptions.RemoveEmptyEntries); responseTmp = responseTitleArr[0]; for (int i = 1; i < responseTitleArr.Length; i++) { responseTmp += keyDistinguished + responseTitleArr[i]; } } responseHtml += responseTmp; responseHtml += "</div>"; //text responseHtml += "<div class='searchResponseText'>"; responseTmp = item.ParagraphText; if (item.ParagraphText != null && item.ParagraphText.Contains(key)) { var responseTitleArr = responseTmp.Split(keyArr, StringSplitOptions.RemoveEmptyEntries); responseTmp = responseTitleArr[0]; for (int i = 1; i < responseTitleArr.Length; i++) { responseTmp += keyDistinguished + responseTitleArr[i]; } } responseHtml += responseTmp; responseHtml += "</div>"; //link responseHtml += "<div class='searchResponseLink'>"; responseTmp = item.ParagraphLinkText; if (item.ParagraphLinkText != null && item.ParagraphLinkText.Contains(key)) { var responseTitleArr = responseTmp.Split(keyArr, StringSplitOptions.RemoveEmptyEntries); responseTmp = responseTitleArr[0]; for (int i = 1; i < responseTitleArr.Length; i++) { responseTmp += keyDistinguished + responseTitleArr[i]; } } responseHtml += responseTmp; responseHtml += "</div>"; responseHtml += "</div>"; } return(Content(responseHtml)); }
public ActionResult SitePages() { var db = new CustomMembershipDB(); return(View(db.SiteMainPages)); }