Exemplo n.º 1
0
 //添加评论
 public ActionResult AddComment(int aid, int id, string content)
 {
     if (Request.Cookies["Login"] == null)
     {
         return(Content("login"));
     }
     else
     {
         HttpCookie cookie = Request.Cookies["Login"];
         JObject    name   = readtoken(cookie.Values["Token"]);
         EComment   etc    = new EComment
         {
             UserName     = name["UserName"].ToString(),
             Animationid  = aid,
             Evaluationid = id,
             Time         = DateTime.Now,
             Likenum      = 0,
             content      = content
         };
         bool add = eManager.AddComment(etc);
         if (add)
         {
             var comm = eManager.GetEComments(id);
             return(PartialView("EComment", comm));
         }
         else
         {
             return(Content("fail"));
         }
     }
 }
Exemplo n.º 2
0
        public Comment Create(Comment comment)
        {
            EComment eComment = EComment(comment);

            eComment = _iDComment.Create(eComment);
            return(Comment(eComment));
        }
Exemplo n.º 3
0
        private Comment Comment(EComment eComment)
        {
            Comment returnComment = new Comment
            {
                CommentId = eComment.CommentId,
                Comments  = eComment.Comments,
            };

            return(returnComment);
        }
Exemplo n.º 4
0
        private EComment EComment(Comment comment)
        {
            EComment returnEComment = new EComment
            {
                CommentId = comment.CommentId,
                Comments  = comment.Comments,
            };

            return(returnEComment);
        }
Exemplo n.º 5
0
 private void stfQualification_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar == 13)
     {
         EComment.Focus();
         e.Handled = true;
     }
     else
     {
         e.Handled = false;
     }
 }
Exemplo n.º 6
0
        public void CommnetTest()
        {
            EUser user = repoUser.Find(x => x.Id == 1);
            ENote note = repoNote.Find(x => x.Id == 3);

            EComment comment = new EComment()
            {
                Text         = "Deneme Yorumu",
                CreateOn     = DateTime.Now,
                ModifiedOn   = DateTime.Now,
                ModifiedUser = "******",
                Note         = note,
                Owner        = user,
            };
            int a = repoComment.Insert(comment);
        }
Exemplo n.º 7
0
        public ActionResult Edit(int?id, string text)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            EComment comment = commentManager.Find(x => x.Id == id.Value);

            if (comment == null)
            {
                return(new HttpNotFoundResult());
            }
            comment.Text = text;

            if (commentManager.Update(comment) > 0)
            {
                return(Json(new { sonuc = true }, JsonRequestBehavior.AllowGet)); //if operation true
            }

            return(Json(new { sonuc = false }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 8
0
        public ActionResult Create(string text, int?noteId)
        {
            ModelState.Remove("CreateOn");
            ModelState.Remove("ModifiedOn");
            ModelState.Remove("ModifiedUser");

            if (ModelState.IsValid)
            {
                if (noteId == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                ENote note = noteManager.Find(x => x.Id == noteId);

                if (note == null)
                {
                    return(new HttpNotFoundResult());
                }
                if (text == "")
                {
                    return(new HttpNotFoundResult());
                }
                EComment comment = new EComment();
                comment.Text  = text;
                comment.Note  = note;
                comment.Owner = SessionManager.User;

                if (commentManager.Insert(comment) > 0)
                {
                    return(Json(new { ress = true }, JsonRequestBehavior.AllowGet));
                }
            }

            return(Json(new { ress = false }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 9
0
        public Comment Read(int CommentId)
        {
            EComment eComment = _iDComment.Read <EComment>(a => a.CommentId == CommentId);

            return(Comment(eComment));
        }
 //添加评论 添加成功返回true
 public bool AddEComment(EComment ect)
 {
     db.EComment.Add(ect);
     return(db.SaveChanges() > 0);
 }
Exemplo n.º 11
0
        protected override void Seed(DatabaseContext context)
        {
            EUser admin = new EUser()
            {
                Name                 = "Sinan",
                Surname              = "Tok",
                Email                = "*****@*****.**",
                ActiveGuid           = Guid.NewGuid(),
                IsActive             = true,
                IsAdmin              = true,
                Username             = "******",
                Password             = "******",
                ProfileImageFileName = "user.jpg",
                CreateOn             = DateTime.Now,
                ModifiedOn           = DateTime.Now.AddMinutes(5),
                ModifiedUser         = "******"
            };

            EUser standartUser = new EUser()
            {
                Name         = "tok",
                Surname      = "Tok",
                Email        = "*****@*****.**",
                ActiveGuid   = Guid.NewGuid(),
                IsActive     = true,
                IsAdmin      = false,
                Username     = "******",
                Password     = "******",
                CreateOn     = DateTime.Now.AddHours(1),
                ModifiedOn   = DateTime.Now.AddMinutes(5),
                ModifiedUser = "******"
            };

            context.EUsers.Add(admin);
            context.EUsers.Add(standartUser);

            for (int h = 0; h < 8; h++)
            {
                EUser user = new EUser()
                {
                    Name         = FakeData.NameData.GetFirstName(),
                    Surname      = FakeData.NameData.GetSurname(),
                    Email        = FakeData.NetworkData.GetEmail(),
                    ActiveGuid   = Guid.NewGuid(),
                    IsActive     = true,
                    IsAdmin      = false,
                    Username     = $"user{h}",
                    Password     = "******",
                    CreateOn     = FakeData.DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now),
                    ModifiedOn   = FakeData.DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now),
                    ModifiedUser = $"user{h}",
                };

                context.EUsers.Add(user);
            }

            context.SaveChanges();

            //user list for using..
            List <EUser> userlist = context.EUsers.ToList();

            //adding fake categories
            for (int i = 0; i < 10; i++)
            {
                ECategory cat = new ECategory()
                {
                    Title        = FakeData.PlaceData.GetStreetName(),
                    Description  = FakeData.PlaceData.GetAddress(),
                    CreateOn     = DateTime.Now,
                    ModifiedOn   = DateTime.Now,
                    ModifiedUser = "******",
                };

                context.ECategories.Add(cat);

                //adding fake notes
                for (int k = 0; k < FakeData.NumberData.GetNumber(5, 9); k++)
                {
                    EUser owner = userlist[FakeData.NumberData.GetNumber(0, userlist.Count - 1)];

                    ENote note = new ENote()
                    {
                        Title        = FakeData.TextData.GetAlphabetical(FakeData.NumberData.GetNumber(5, 25)),
                        Text         = FakeData.TextData.GetSentences(FakeData.NumberData.GetNumber(1, 3)),
                        Category     = cat,
                        IsDraft      = false,
                        LikeCount    = FakeData.NumberData.GetNumber(1, 9),
                        Owner        = owner,
                        CreateOn     = FakeData.DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now),
                        ModifiedOn   = FakeData.DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now),
                        ModifiedUser = owner.Username,
                    };

                    cat.Notes.Add(note);


                    //adding fake comments
                    for (int j = 0; j < FakeData.NumberData.GetNumber(3, 5); j++)
                    {
                        EUser commnentOwner = userlist[FakeData.NumberData.GetNumber(0, userlist.Count - 1)];

                        EComment comment = new EComment()
                        {
                            Text         = FakeData.TextData.GetSentence(),
                            Owner        = commnentOwner,
                            CreateOn     = FakeData.DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now),
                            ModifiedOn   = FakeData.DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now),
                            ModifiedUser = commnentOwner.Username,
                        };

                        note.Comments.Add(comment);
                    }

                    //adding fake likes

                    for (int p = 0; p < note.LikeCount; p++)
                    {
                        ELiked like = new ELiked()
                        {
                            LikedUser = userlist[p]
                        };

                        note.Likes.Add(like);
                    }
                }
            }

            context.SaveChanges();
        }
Exemplo n.º 12
0
 /// <summary>
 /// 判断是否添加评论
 /// </summary>
 /// <param name="ect"></param>
 /// <returns></returns>
 public bool AddComment(EComment ect)
 {
     return(evaluation.AddEComment(ect));
 }