Ejemplo n.º 1
0
        public JObject GetDreamInfo(int id)
        {
            var result = context.Dreams.SingleOrDefault(status => status.DreamId == id);

            if (result == null)
            {
                return(null);
            }
            JObject obj = new JObject();

            obj.AddStatus(result.Status);
            context.Entry(result).Collection(w => w.Steps);
            JArray steps = new JArray();

            obj.Add("steps", steps);
            foreach (var dreamStep in result.Steps)
            {
                JObject stepContent = new JObject
                {
                    { "id", dreamStep.StepId },
                    { "content", dreamStep.Status["content"] },
                    { "isremoved", dreamStep.IsRemoved },
                    { "lastupdated", dreamStep.Status.ContainsKey("lastupdated") ? dreamStep.Status["lastupdated"] : "0" }
                };
                steps.Add(stepContent);
            }

            return(obj);
        }
Ejemplo n.º 2
0
        public JObject GetUserInfo(int id)
        {
            var result = context.UserInfo.SingleOrDefault(status => status.UserId == id);

            if (result == null)
            {
                return(null);
            }
            JObject obj = new JObject();

            obj.AddStatus(result.Status);
            context.Entry(result).Collection(w => w.Dreams);
            JArray dreams = new JArray();

            obj.Add("dreams", dreams);
            foreach (var dataDream in result.Dreams)
            {
                JObject dreamContent = new JObject
                {
                    { "id", dataDream.DreamId },
                    { "title", dataDream.Status["title"] },
                    { "private", dataDream.Status["private"] },
                    { "lastupdated", dataDream.Status.ContainsKey("lastupdated")? dataDream.Status["lastupdated"] : "0" }
                };
                dreams.Add(dreamContent);
            }
            return(obj);
        }
Ejemplo n.º 3
0
        public JObject GetCommentInfo(int id)
        {
            var result = context.Comments.SingleOrDefault(w => w.CommentId == id);

            if (result == null)
            {
                return(null);
            }
            JObject obj = new JObject();

            obj.AddStatus(result.Status);
            obj.Add("isremoved", result.IsRemoved);
            return(obj);
        }
Ejemplo n.º 4
0
        public JObject GetStepInfo(int id)
        {
            var result = context.Steps.SingleOrDefault(status => status.StepId == id);

            if (result == null)
            {
                return(null);
            }
            JObject obj = new JObject();

            obj.AddStatus(result.Status);
            context.Entry(result).Collection(w => w.Comments);
            JArray comments = new JArray();

            obj.Add("comment", comments);
            obj.Add("isremoved", result.IsRemoved);
            foreach (var stepComment in result.Comments)
            {
                JObject stepContent = new JObject
                {
                    { "id", stepComment.Status["id"] },
                    { "content", stepComment.Status["content"] },
                    { "isremoved", stepComment.IsRemoved },
                    { "user", stepComment.Status["user"] }
                };
                comments.Add(stepContent);
            }
            JArray images = new JArray();

            obj.Add("images", images);
            foreach (var stepImage in result.Images)
            {
                images.Add(stepImage);
            }

            return(obj);
        }