Esempio n. 1
0
        private void share()
        {
            if (Provider.User.IsAnonim())
                return;

            int pid = 0;
            int.TryParse(context.Request["pid"], out pid);
            if (pid == 0)
                throw new Exception("Post not found");

            Post post = Provider.Database.Read<Post>(pid);

            if ((Provider.Database.Read<User>(post.InsertUserId)).Settings.NeedsConfirmation)
                throw new Exception("This user does not let his posts to be shared.");

            Post p = new Post
            {
                LangId = Provider.CurrentLanguage.Id,
                Metin = post.Metin,
                OriginalPostId = post.OriginalPostId > 0 ? post.OriginalPostId : post.Id,
                Picture = post.Picture
            };
            p.Save();

            context.Response.Write(new Result { Data = true }.ToJSON());
        }
Esempio n. 2
0
        private void post()
        {
            if (Provider.User.IsAnonim())
                return;

            int lat = 0;
            int.TryParse(context.Request["lat"], out lat);
            int lng = 0;
            int.TryParse(context.Request["lng"], out lng);
            string metin = context.Request["metin"];
            if (string.IsNullOrWhiteSpace(metin) && (Provider.Request.Files["Picture"] == null || Provider.Request.Files["Picture"].ContentLength == 0))
                throw new Exception("Post empty");
            int replyToPostId = 0;
            int.TryParse(context.Request["replyToPostId"], out replyToPostId);

            Post replyToPost = null;
            if(replyToPostId>0) replyToPost = Provider.Database.Read<Post>(replyToPostId);

            context.Response.ContentType = "text/html";

            try
            {
                Post p = new Post
                {
                    LangId = Provider.CurrentLanguage.Id,
                    Lat = lat,
                    Lng = lng,
                    Metin = metin==null ? "" : metin,
                    ReplyToPostId = replyToPostId>0 ? (replyToPost.OriginalPost == null ? replyToPostId : replyToPost.OriginalPost.Id) : 0
                };

                p.Save();

                ViewPost vp = new ViewPost()
                    {
                        SharerNick = "",
                        UserAvatar = Provider.GetThumbPath(p.InsertUser.Avatar, 48, 48, false),
                        UserFullName = p.InsertUser.FullName,
                        UserNick = p.InsertUser.Nick
                    };
                p.CopyPropertiesWithSameName(vp);

                context.Response.Write("<html><head></head><body><script>window.parent.paylas(" + vp.ToJSON() + ");</script></body></html>");
            }
            catch(Exception ex)
            {
                context.Response.Write("<html><head></head><body><script>window.parent.niceAlert(" + ex.Message.ToJS() + ");</script></body></html>");
            }
        }