public ActionResult Create([Bind(Include = "UserId,AuthorityId,UserName,Password,Email,Name,Images")] Users users, HttpPostedFileBase file) { if (ModelState.IsValid) { if (file != null) { ImageUpload imageUpload = new ImageUpload(); users.Images = imageUpload.ImageResizeUser(file, 240, 240); } else { ModelState.AddModelError("Fotoğraf", "Fotoğraf Eklemediniz"); } db.Users.Add(users); users.AuthorityId = 7; db.Users.Add(users); db.SaveChanges(); Session["UserId"] = users.UserId; Session["UserName"] = users.UserName; return(RedirectToAction("Index", "Home")); } return(View(users)); }
public ActionResult Create([Bind(Include = "CategoryId,CategoryName")] Category category) { if (ModelState.IsValid) { db.Category.Add(category); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(category)); }
public ActionResult Create([Bind(Include = "LabelId,LabelName")] Labels labels) { if (ModelState.IsValid) { db.Labels.Add(labels); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(labels)); }
public ActionResult Create([Bind(Include = "AuthorityId,Authority1")] Authority authority) { if (ModelState.IsValid) { db.Authority.Add(authority); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(authority)); }
public ActionResult Create([Bind(Include = "ArticleId,CategoryId,Baslik,ImageUrl,ImageUrlt,Description,Date,Reads,UserId")] Article article) { if (ModelState.IsValid) { db.Article.Add(article); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CategoryId = new SelectList(db.Category, "CategoryId", "CategoryName", article.CategoryId); return(View(article)); }
public ActionResult Create([Bind(Include = "ComentId,ArticleId,UserId,Description,Date")] Comments comments) { if (ModelState.IsValid) { db.Comments.Add(comments); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ArticleId = new SelectList(db.Article, "ArticleId", "Baslik", comments.ArticleId); ViewBag.UserId = new SelectList(db.Users, "UserId", "UserName", comments.UserId); return(View(comments)); }
public ActionResult Create([Bind(Include = "UserId,AuthorityId,UserName,Password,Email,Name,Images")] Users users, HttpPostedFileBase file) { if (ModelState.IsValid) { if (file != null) { ImageUpload imageUpload = new ImageUpload(); users.Images = imageUpload.ImageResizeUser(file, 240, 240); } db.Users.Add(users); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.AuthorityId = new SelectList(db.Authority, "AuthorityId", "Authority1", users.AuthorityId); return(View(users)); }
public ActionResult Create([Bind(Include = "ArticleId,CategoryId,Baslik,ImageUrl,ImageUrlt,Description,Date,Reads,Labels,UserId")] Article article, FormCollection form, string editor1, string etiket, IEnumerable <HttpPostedFileBase> files, HttpPostedFileBase file0, HttpPostedFileBase file1) { if (ModelState.IsValid) { ImageUpload imageUpload = new ImageUpload(); article.Date = DateTime.Now; string sightlist = form["sightlist"]; if (files.ElementAt(1) != null && files.ElementAt(0) != null) { file0 = files.ElementAt(0); file1 = files.ElementAt(1); article.ImageUrl = imageUpload.ImageResizeFirst(file0, 240, 240); article.ImageUrlt = imageUpload.ImageResizeSecond(file1, 100, 200);; } else if (files.ElementAt(0) != null) { file0 = files.ElementAt(0); article.ImageUrl = imageUpload.ImageResizeFirst(file0, 240, 240); } else if (files.ElementAt(1) != null) { file1 = files.ElementAt(1); article.ImageUrlt = imageUpload.ImageResizeSecond(file1, 240, 240); } var karma = ""; if (etiket == "" && sightlist == null) { article.Labels.Clear(); } else if (sightlist != null && sightlist != "") { string[] etiketdizi = sightlist.Split(','); foreach (var item in etiketdizi) { var gecen = db.Labels.Find((Convert.ToInt32(item))); if (item == "") { continue; } else { karma = karma + gecen.LabelName + ","; } } karma = karma + etiket; } if (karma != null && karma != "") { string[] etiketdizi = karma.Split(','); foreach (var item in etiketdizi) { if (item == "") { continue; } if (db.Labels.Any(p => p.LabelName.Equals(item))) { var gecen = db.Labels.Where(p => p.LabelName.Equals(item)).First().LabelId; article.Labels.Add(db.Labels.Find(gecen)); } else { var yenietikets = new Labels { LabelName = item }; if (yenietikets.ToString().Length <= 50) { article.Labels.Add(yenietikets); } } } } else { string[] etiketdizi = etiket.Split(','); foreach (var item in etiketdizi) { if (item == "") { continue; } else if (db.Labels.Any(p => p.LabelName.Equals(item))) { var gecen = db.Labels.Where(p => p.LabelName.Equals(item)).First().LabelId; article.Labels.Add(db.Labels.Find(gecen)); } else { var yenietikets = new Labels { LabelName = item }; if (yenietikets.ToString().Length <= 50) { article.Labels.Add(yenietikets); } } } karma = karma + etiket; } article.Description = editor1; ViewBag.etiket = etiket; db.Article.Add(article); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CategoryId = new SelectList(db.Category, "CategoryId", "CategoryName", article.CategoryId); return(View(article)); }