diff --git a/Controllers/newsController.cs b/Controllers/newsController.cs index 264a34e..cc60667 100644 --- a/Controllers/newsController.cs +++ b/Controllers/newsController.cs @@ -121,19 +121,42 @@ namespace WebApplication1.Controllers // more details see https://go.microsoft.com/fwlink/?LinkId=317598. [HttpPost] [ValidateAntiForgeryToken] - public ActionResult Create([Bind(Include = "ID,title,image,link,summary,cat,tag,publishDate,userID,Content,views")] news news) + public ActionResult Create([Bind(Include = "ID,title,image,link,summary,cat,tags,publishDate,userID,Content,views")] news news, List Tags, List Cat) { if (ModelState.IsValid) { if (Request.Files.Count > 0) { setLists(); - /* - string x = news.tag; - var y = news.tag[1]; - */ - if (news.title != null && news.link != null && news.cat != null && news.tag != null) + + + + + if (news.title != null && news.link != null && Cat != null && Tags != null) { + + news.tag = ""; + foreach (string T in Tags) + { + if (T != Tags[0]) + { + news.tag += " ,"; + news.tag += T; + } + else + news.tag += T; + } + news.cat = ""; + foreach (string c in Cat) + { + if (c != Cat[0]) + { + news.cat+= " ,"; + news.cat += c; + } + else + news.cat += c; + } var image = Request.Files[0]; if (image.ContentLength > 1024 * 1024) { diff --git a/Media/news/32wiF8mzgi.jpg b/Media/news/32wiF8mzgi.jpg new file mode 100644 index 0000000..be90bc6 Binary files /dev/null and b/Media/news/32wiF8mzgi.jpg differ diff --git a/Media/news/5RCYg4F954.jpg b/Media/news/5RCYg4F954.jpg new file mode 100644 index 0000000..be90bc6 Binary files /dev/null and b/Media/news/5RCYg4F954.jpg differ diff --git a/Media/news/DhunrFmH5e.jpg b/Media/news/DhunrFmH5e.jpg new file mode 100644 index 0000000..be90bc6 Binary files /dev/null and b/Media/news/DhunrFmH5e.jpg differ diff --git a/Media/news/i08QfDIQ70.jpg b/Media/news/i08QfDIQ70.jpg new file mode 100644 index 0000000..be90bc6 Binary files /dev/null and b/Media/news/i08QfDIQ70.jpg differ diff --git a/Media/news/orYf1iXWSH.jpg b/Media/news/orYf1iXWSH.jpg new file mode 100644 index 0000000..be90bc6 Binary files /dev/null and b/Media/news/orYf1iXWSH.jpg differ diff --git a/Media/news/rQISg2NRaA.jpg b/Media/news/rQISg2NRaA.jpg new file mode 100644 index 0000000..be90bc6 Binary files /dev/null and b/Media/news/rQISg2NRaA.jpg differ diff --git a/Media/news/zF9LapiTFm.jpg b/Media/news/zF9LapiTFm.jpg new file mode 100644 index 0000000..be90bc6 Binary files /dev/null and b/Media/news/zF9LapiTFm.jpg differ diff --git a/Views/news/Create.cshtml b/Views/news/Create.cshtml index a48c1f7..cffbff1 100644 --- a/Views/news/Create.cshtml +++ b/Views/news/Create.cshtml @@ -41,7 +41,7 @@
- @foreach (var item in ViewBag.categoryTitle) { @@ -54,7 +54,7 @@
@Html.LabelFor(model => model.tag, htmlAttributes: new { @class = "control-label col-md-2" })
- @foreach (var item in ViewBag.tagTitle) {