Example #1
0
 public ActionResult Index(YorumViewModel yvm)
 {
     if (ModelState.IsValid)
     {
         Yorum yorum = new Yorum()
         {
             KullaniciId = User.Identity.GetUserId(),
             BlogId      = yvm.BlogId,
             Icerik      = yvm.Icerik
         };
         db.Yorumlar.Add(yorum);
         db.SaveChanges();
         return(Json(new { kullaniciAdi = User.Identity.GetUserName(), icerik = yvm.Icerik }));
     }
     return(Json(ModelState));
 }
Example #2
0
        public ActionResult Detay(int id) // Tamamen döndürülen obje ile alakalı bir sorun var.
        {
            Yorum data = _yorumRepository.GetByID(id);

            if (data == null)
            {
                return(Json(new {}, JsonRequestBehavior.AllowGet));
            }
            YorumViewModel viewData = new YorumViewModel {
                ID         = data.ID,
                AdSoyad    = data.Adsoyad,
                Mail       = data.Mail,
                Site       = data.Site,
                YorumMesaj = data.YorumMesaj,
                BlogAdi    = data.Blog.Baslik,
                Onay       = data.Onay
            };

            return(PartialView("_Detay", viewData));
        }
Example #3
0
        public ActionResult Show(int id, string slug, YorumViewModel commentViewModel)
        {
            var post = db.Kitap.Find(id);

            if (post == null)
            {
                return(HttpNotFound());
            }
            if (post.Slug != slug)
            {
                return(RedirectToAction("Show", new { id = id, slug = post.Slug }));
            }

            if (ModelState.IsValid)
            {
                string mail    = Session["mail"].ToString();
                var    yazar   = db.Uyeler.FirstOrDefault(z => z.Mail == mail);
                var    comment = new Yorums
                {
                    YazarId          = yazar.Id,
                    Icerik           = commentViewModel.Content,
                    YayinlanmaZamani = DateTime.Now,
                    DegistirmeZamani = DateTime.Now,
                    Durum            = true,
                    KitapId          = id,
                    ParentId         = commentViewModel.ParentId
                };
                db.Yorums.Add(comment);
                db.SaveChanges();
                return(Redirect(Url.RouteUrl(new { controller = "Kitap", action = "Show", id = id, slug = slug, commentSuccess = true }) + "#leave-a-comment"));
            }

            var vm = new KitapShowViewModel
            {
                Kitap          = post,
                YorumViewModel = commentViewModel
            };

            return(View(vm));
        }
        public async Task <IActionResult> Comment(YorumViewModel vm)
        {
            var temp = vm.UserName;

            if (!ModelState.IsValid)
            {
                return(RedirectToAction("mekan", temp, new { id = vm.mekanId }));
            }
            var mekan = _depo.MekanGetir(vm.mekanId);

            if (vm.MainCommentId == 0)
            {
                mekan.MainComments = mekan.MainComments ?? new List <MainComment>();
                mekan.MainComments.Add(new MainComment
                {
                    Message  = vm.Message,
                    Created  = DateTime.Now,
                    UserName = _userManager.GetUserName(User),
                });
                _depo.YorumEkle(mekan);
            }
            else
            {
                var comment = new SubComment
                {
                    MainCommentId = vm.MainCommentId,
                    Message       = vm.Message,
                    Created       = DateTime.Now,
                    UserName      = _userManager.GetUserName(User),
                };
                _depo.AltYorumEkle(comment);
            }
            await _depo.SaveChangesAsync();

            return(RedirectToAction("mekan", temp, new { id = vm.mekanId }));
        }