public PartialViewResult createCont(int pageID, string cont, int aktif) { try { //int a = Convert.ToInt32(collection[0]); List <Content> co = datas.Contents.Where(t => t.pageId == pageID).ToList(); foreach (var item in co) { item.status = 2; } Content conte = new Content { pageId = pageID, contenttext = cont, status = 1 }; datas.Contents.Add(conte); datas.SaveChanges(); List <Content> contig = datas.Contents.ToList(); return(PartialView("createCont", contig)); } catch { return(PartialView("createCont")); } return(PartialView("createCont")); }
public ActionResult Create(FormCollection frm) { if (user == null) { return(RedirectToAction("Login", "Account")); } if (Convert.ToInt32(frm["statussec"]) == 1) { foreach (var item in datas.Contacts.ToList()) { item.status = 2; } } Contact cnt = new Contact(); cnt.adress = frm["adress"].ToString(); cnt.email = frm["email"].ToString(); cnt.phone = frm["phone"].ToString(); cnt.status = Convert.ToInt32(frm["statussec"]); try { // TODO: Add insert logic here datas.Contacts.Add(cnt); datas.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View("Index")); } }
public ActionResult Create(FormCollection frm) { if (user == null) { return(RedirectToAction("Login", "Account")); } //try //{ Slider sli = new Slider(); sli.buyuk = frm["buyuk"].ToString(); sli.orta = frm["orta"].ToString(); sli.kucuk = frm["kucuk"].ToString(); if (Request.Files.Count > 0) { //string path = Server.MapPath("/"); string path = Server.MapPath("/"); sli.path = path; if (Directory.Exists(path + "/SliderPics") == false) { Directory.CreateDirectory(path + "SliderPics/"); } if (!string.IsNullOrEmpty(Request.Files["pic"].FileName)) { Request.Files["pic"].SaveAs(path + "SliderPics/" + Request.Files["pic"].FileName); } } sli.sliderContent = string.IsNullOrEmpty(Request.Files["pic"].FileName) == true ? "" : "SliderPics/" + Request.Files["pic"].FileName; if (Convert.ToInt32(frm["baslikSec"]) == (-1)) { sli.byaziid = 22; } else { sli.byaziid = Convert.ToInt32(frm["baslikSec"]); } sli.status = Convert.ToInt32(frm["statussec"]); datas.Sliders.Add(sli); datas.SaveChanges(); // TODO: Add insert logic here return(RedirectToAction("Index")); //} //catch //{ // return RedirectToAction("Index"); //} }
public ActionResult DanısanYorum(FormCollection frm) { if (ModelState.IsValid) { if (frm[1] != "" || frm[0] != "") { yorumDanisan yrm = new yorumDanisan { email = frm[0], kadi = frm[1], status = 2, comment = frm[2] }; try { datas.yorumDanisans.Add(yrm); datas.SaveChanges(); ViewBag.mesaj = "Yorumunuz Başarıyla Kaydedilmiştir."; return(View()); } catch (Exception ex) { ViewBag.mesaj = "Bilgilerinizi eksik veya hatalı girdiniz."; } } } ViewBag.mesaj = "Bilgilerinizi eksik veya hatalı girdiniz."; return(View()); }
public ActionResult Create(FormCollection frm) { sertifikalar srf = new sertifikalar(); srf.name = frm["name"].ToString(); if (Request.Files.Count > 0) { string path = Server.MapPath("/"); srf.folder = path; if (Directory.Exists(path + "/Belgeler") == false) { Directory.CreateDirectory(path + "Belgeler/"); } if (!string.IsNullOrEmpty(Request.Files["pic"].FileName)) { Request.Files["pic"].SaveAs(path + "Belgeler/" + Request.Files["pic"].FileName); } } srf.folder = string.IsNullOrEmpty(Request.Files["pic"].FileName) == true ? "" : "Belgeler/" + Request.Files["pic"].FileName; try { // TODO: Add insert logic here datas.sertifikalars.Add(srf); datas.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult LogOut() { HttpCookie c*k = HttpContext.Request.Cookies["tk"]; oylmzEntities datas = new oylmzEntities(); Token token = datas.Tokens.Where(t => t.tokentext == c*k.Value && t.enddate > DateTime.Now).FirstOrDefault(); token.enddate = DateTime.Now.AddHours(-2); datas.SaveChanges(); return(RedirectToAction("Index", "Home")); }
public ActionResult Create(FormCollection frm) { if (user == null) { return(RedirectToAction("Login", "Account")); } try { Page pages = new Page(); pages.name = frm[1].ToString(); datas.Pages.Add(pages); datas.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Edit(int id, FormCollection frm) { if (user == null) { return(RedirectToAction("Login", "Account")); } try { // TODO: Add update logic here yorumlar blg = datas.yorumlars.Where(t => t.id == id).FirstOrDefault(); blg.satutus = Convert.ToInt32(frm["statussec"]); datas.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult altbaslik(FormCollection frm) { if (user == null) { return(RedirectToAction("Login", "Account")); } try { altbaslik alt = new altbaslik(); alt.adi = frm["adi"].ToString(); datas.altbasliks.Add(alt); datas.SaveChanges(); return(RedirectToAction("altbaslikIndex")); } catch { return(View()); } }
public ActionResult Login(admin.Models.LoginViewModel userdata) { if (!ModelState.IsValid) { return(View()); } oylmzEntities datas = new oylmzEntities(); User loginUser = datas.Users.Where(t => t.userName == userdata.userName && t.password == userdata.password).FirstOrDefault(); if (loginUser == null) { ViewBag.hata = "Kullanıcı adı veya şifre hatalı"; return(View()); } Token token = new Token(); do { token.enddate = DateTime.Now.AddHours(2); token.tokentext = RandomSfr.Generate(10); } while (datas.Tokens.Count(t => t.tokentext == token.tokentext) > 0); token.userId = loginUser.Id; datas.Tokens.Add(token); datas.SaveChanges(); HttpCookie c*k = new HttpCookie("tk"); c*k.Value = token.tokentext; c*k.Expires = DateTime.Now.AddHours(2); Response.Cookies.Add(c*k); return(RedirectToAction("Index", "Home")); }
public ActionResult Create(FormCollection frm) { if (user == null) { return(RedirectToAction("Login", "Account")); } BlogYazi blg = new BlogYazi(); blg.Baslik = frm["Baslik"].ToString(); blg.Content = frm["editor1"].ToString(); blg.tanitimYazi = frm["tanitim"].ToString(); blg.tarih = DateTime.Now; blg.aySira = DateTime.Now.Month; switch (DateTime.Now.Month) { case 1: blg.aylar = "Ocak"; break; case 2: blg.aylar = "Şubat"; break; case 3: blg.aylar = "Mart"; break; case 4: blg.aylar = "Nisan"; break; case 5: blg.aylar = "Mayıs"; break; case 6: blg.aylar = "Haziran"; break; case 7: blg.aylar = "Temmuz"; break; case 8: blg.aylar = "Ağustos"; break; case 9: blg.aylar = "Eylül"; break; case 10: blg.aylar = "Ekim"; break; case 11: blg.aylar = "Kasım"; break; case 12: blg.aylar = "Aralık"; break; default: break; } if (Request.Files.Count > 0) { string path = Server.MapPath("/"); blg.path = path; if (Directory.Exists(path + "/BlogPics") == false) { Directory.CreateDirectory(path + "BlogPics/"); } if (!string.IsNullOrEmpty(Request.Files["pic"].FileName)) { Request.Files["pic"].SaveAs(path + "BlogPics/" + Request.Files["pic"].FileName); } } blg.folder = string.IsNullOrEmpty(Request.Files["pic"].FileName) == true ? "" : " BlogPics/" + Request.Files["pic"].FileName; try { // TODO: Add insert logic here datas.BlogYazis.Add(blg); datas.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult yorumgnder(FormCollection frm) { int blgid = Convert.ToInt32(frm[0]); if (frm[2] != "") { if (frm[1] != "") { if (ModelState.IsValid) { yorumlar yrm = new yorumlar { mail = frm[1], content = frm[2], satutus = 2, blogid = Convert.ToInt32(frm[0]), date = DateTime.Now.Date, }; try { datas.yorumlars.Add(yrm); datas.SaveChanges(); ViewBag.mesaj = "Yorumunuz Başarıyla Kaydedilmiştir."; BlogYazi blg = datas.BlogYazis.Where(t => t.id == blgid).FirstOrDefault(); List <yorumlar> yorm = datas.yorumlars.Where(t => t.blogid == blgid && t.satutus == 1).OrderBy(t => t.id).ToList(); Models.BlogViewMoldels blgg = new Models.BlogViewMoldels(); blgg.yrms = yorm; blgg.blogid = blgid; blgg.Baslik = blg.Baslik; blgg.aySira = blg.aySira; blgg.Content = blg.Content; blgg.folder = blg.folder; blgg.path = blg.path; return(View("detay", blgg)); } catch (Exception ex) { ViewBag.mesaj = "Bilgilerinizi eksik veya hatalı girdiniz."; BlogYazi blg = datas.BlogYazis.Where(t => t.id == blgid).FirstOrDefault(); List <yorumlar> yorm = datas.yorumlars.Where(t => t.blogid == blgid && t.satutus == 1).OrderBy(t => t.id).ToList(); Models.BlogViewMoldels blgg = new Models.BlogViewMoldels(); blgg.yrms = yorm; blgg.blogid = blgid; blgg.Baslik = blg.Baslik; blgg.aySira = blg.aySira; blgg.Content = blg.Content; blgg.folder = blg.folder; blgg.path = blg.path; return(View("detay", blgg)); } } } } BlogYazi blggg = datas.BlogYazis.Where(t => t.id == blgid).FirstOrDefault(); List <yorumlar> yormm = datas.yorumlars.Where(t => t.blogid == blgid && t.satutus == 1).OrderBy(t => t.id).ToList(); Models.BlogViewMoldels blgggg = new Models.BlogViewMoldels(); blgggg.yrms = yormm; blgggg.blogid = blgid; blgggg.Baslik = blggg.Baslik; blgggg.aySira = blggg.aySira; blgggg.Content = blggg.Content; blgggg.folder = blggg.folder; blgggg.path = blggg.path; ViewBag.mesaj = "Bilgilerinizi eksik veya hatalı girdiniz."; return(View("detay", blgggg)); }