예제 #1
0
        public ActionResult Edit(int id, HttpPostedFileBase Foto, Forumm makale)

        {
            try
            {
                var makales = db.Fora.Where(m => m.ForumId == id).SingleOrDefault();

                if (Foto != null)
                {
                    if (System.IO.File.Exists(Server.MapPath(makales.Foto)))
                    {
                        System.IO.File.Delete(Server.MapPath(makales.Foto));
                    }

                    WebImage img      = new WebImage(Foto.InputStream);
                    FileInfo fotoinfo = new FileInfo(Foto.FileName);

                    string newfoto = Guid.NewGuid().ToString() + fotoinfo.Extension;
                    img.Resize(800, 350);
                    img.Save("~/Uploads/MakaleFoto/" + newfoto);
                    makales.Foto       = "~/Uploads/MakaleFoto/" + newfoto;
                    makales.Baslik     = makale.Baslik;
                    makales.Icerik     = makale.Icerik;
                    makales.KategoriId = makale.KategoriId;
                    db.SaveChanges();
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
 public IEnumerable <Post> GetFilteredPosts(Forumm forum, string searchQuery)
 {
     return(string.IsNullOrEmpty(searchQuery)
         ? forum.Posts
         : forum.Posts.Where(post
                             => post.Title.Contains(searchQuery) ||
                             post.Content.Contains(searchQuery)));
 }
 private ForumListingModel BuildForumListing(Forumm forum)
 {
     return(new ForumListingModel
     {
         Id = forum.Id,
         Name = forum.Title,
         Description = forum.Description,
         ImageUrl = forum.ImageUrl
     });
 }
        public async Task <IActionResult> AddForum(AddForumModel model)
        {
            if (model.ImageUpload != null)
            {
                var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot\\images\\forum", model.ImageUpload.FileName);
                using (var stream = new FileStream(path, FileMode.Create))
                {
                    await model.ImageUpload.CopyToAsync(stream);
                }
            }
            var forum = new Forumm
            {
                Title       = model.Title,
                Description = model.Description,
                Created     = DateTime.Now,
                ImageUrl    = "/images/forum/" + model.ImageUpload.FileName
            };

            await _forumService.Create(forum);

            return(RedirectToAction("Index", "Forum"));
        }
예제 #5
0
        public ActionResult Create(Forumm forum, string etiketler, HttpPostedFileBase Foto)
        {
            if (ModelState.IsValid)
            {
                if (Foto != null)
                {
                    WebImage img      = new WebImage(Foto.InputStream);
                    FileInfo fotoinfo = new FileInfo(Foto.FileName);

                    string newfoto = Guid.NewGuid().ToString() + fotoinfo.Extension;
                    img.Resize(800, 350);
                    img.Save("~/Uploads/MakaleFoto/" + newfoto);
                    forum.Foto = "~/Uploads/MakaleFoto/" + newfoto;
                }
                db.Fora.Add(forum);

                db.SaveChanges();
                if (etiketler != null)

                {
                    string[] etiketdizi = etiketler.Split(',');
                    foreach (var i in etiketdizi)
                    {
                        var yenietiket = new Ticket {
                            EtiketAdi = i
                        };
                        db.Tickets.Add(yenietiket);
                        forum.Tickets.Add(yenietiket);
                    }
                }


                return(RedirectToAction("Index"));
            }

            return(View(forum));
        }///
예제 #6
0
 public IEnumerable <Post> GetFilteredPosts(Forumm forum, string searchQuery)
 {
     return(_postDal.GetFilteredPosts(forum, searchQuery));
 }
예제 #7
0
 public Task Create(Forumm forum)
 {
     return(_forumDal.Create(forum));
 }