Esempio n. 1
0
            public static bool Post(string guid, bool isComment, string key)
            {
                //check if its disliked
                if (DislikeClass.CheckExistence(guid, isComment, key))
                {
                    return(false);
                }
                //Check if there is already a like by the user
                if (CheckExistence(guid, isComment, key))
                {
                    //delete the like
                    Delete(guid, isComment, key);
                    return(false);
                }
                //post new like
                Likes like = new Likes
                {
                    Owner_Guid = key,
                };

                if (isComment)
                {
                    like.Comment_Guid = guid;
                }
                else
                {
                    like.Confess_Guid = guid;
                }
                like.Id = Logical.Setter(like.Id);
                contextLite.Likes.Insert(like);
                //context.Likes.InsertOne(like);
                return(true);
            }
Esempio n. 2
0
            private static ConfessLoader GetConfessLoader(Confess dt, string key)
            {
                ConfessLoader loader = new ConfessLoader
                {
                    Body         = dt.Body,
                    Category     = dt.Category,
                    Date         = Shared.TimeAgo.Ago(dt.Date),//$"{dt.Date.ToLongDateString()} {dt.Date.ToShortTimeString()}",
                    DateReal     = dt.Date,
                    DisLikes     = DislikeClass.GetCount(dt.Guid, false),
                    Likes        = LikeClass.GetCount(dt.Guid, false),
                    Guid         = dt.Guid,
                    Owner_Guid   = dt.Owner_Guid,
                    Title        = dt.Title,
                    CommentCount = CommentClass.GetCommentCount(dt.Guid),
                    Seen         = SeenClass.GetCount(dt.Guid)
                };

                //load colors
                if (LikeClass.CheckExistence(dt.Guid, false, key))
                {
                    loader.LikeColorString = "#1976D2";
                }

                if (DislikeClass.CheckExistence(dt.Guid, false, key))
                {
                    loader.DislikeColorString = "#1976D2";
                }

                return(loader);
            }
Esempio n. 3
0
            private static CommentLoader GetLoader(Comment dt, string key)
            {
                CommentLoader loader = new CommentLoader
                {
                    Body                   = dt.Body,
                    Date                   = Shared.TimeAgo.Ago(dt.Date),// $"{CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedDayName(dt.Date.DayOfWeek)}, {CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedMonthName(dt.Date.Month)} {dt.Date.Day}, {dt.Date.Year} {dt.Date.ToShortTimeString()}",
                    DisLikes               = DislikeClass.GetCount(dt.Guid, true),
                    DateReal               = dt.Date,
                    Likes                  = LikeClass.GetCount(dt.Guid, true),
                    Guid                   = dt.Guid,
                    Owner_Guid             = dt.Owner_Guid,
                    Quote                  = dt.Quote,
                    QuotedCommentAvailable = dt.QuotedCommentAvailable,
                    Confess_Guid           = dt.Confess_Guid
                };

                //load colors
                if (LikeClass.CheckExistence(dt.Guid, true, key))
                {
                    loader.LikeColorString = "#1976D2";
                }

                if (DislikeClass.CheckExistence(dt.Guid, true, key))
                {
                    loader.DislikeColorString = "#1976D2";
                }
                if (dt.Owner_Guid == key)
                {
                    loader.DeleteVisibility = true;
                }

                return(loader);
            }
Esempio n. 4
0
            private static List <ConfessLoader> GetConfessLoader(List <Confess> list, string key)
            {
                List <ConfessLoader> loaders = new List <ConfessLoader>();

                foreach (Confess dt in list)
                {
                    ConfessLoader loader = new ConfessLoader
                    {
                        Body         = dt.Body,
                        Category     = dt.Category,
                        Date         = Shared.TimeAgo.Ago(dt.Date),// $"{dt.Date.ToLongDateString()} {dt.Date.ToShortTimeString()}",
                        DateReal     = dt.Date,
                        DisLikes     = DislikeClass.GetCount(dt.Guid, false),
                        Likes        = LikeClass.GetCount(dt.Guid, false),
                        Guid         = dt.Guid,
                        Owner_Guid   = dt.Owner_Guid,
                        Title        = dt.Title,
                        CommentCount = CommentClass.GetCommentCount(dt.Guid),
                        Seen         = SeenClass.GetCount(dt.Guid)
                    };
                    //load colors
                    if (LikeClass.CheckExistence(dt.Guid, false, key))
                    {
                        loader.LikeColorString = "#1976D2";
                    }

                    if (DislikeClass.CheckExistence(dt.Guid, false, key))
                    {
                        loader.DislikeColorString = "#1976D2";
                    }

                    loaders.Add(loader);
                    loader = new ConfessLoader();
                }
                loaders = loaders.OrderByDescending(d => d.DateReal).Reverse().ToList();
                return(loaders);
            }