public static List <CommentSpecification> Get(int commentId)
        {
            var    db  = CommentSpecification.GetDatabase();
            string sql = @"
                SELECT * FROM CommentSpecifications
                WHERE
                    CommentId = '" + commentId + @"'
                ORDER BY
                    CommentId,
                    SpecificationId";

            return(db.ExecuteQuery <CommentSpecification>(sql));
        }
        public static void DeleteAll()
        {
            var db = CommentSpecification.GetDatabase();

            db.ExecuteNonQuery("DELETE FROM CommentStandardRooms");
        }
예제 #3
0
        public static void Update(List <CommentCategory> categories)
        {
            //必要なプロパティを埋める
            int categoryId = 1;
            int commentId  = 1;

            foreach (var category in categories)
            {
                category.Id     = categoryId;
                category.SortNo = categoryId;

                int commentSortNo = 1;
                foreach (var comment in category.Comments)
                {
                    comment.Id         = commentId;
                    comment.SortNo     = commentSortNo;
                    comment.CategoryId = categoryId;

                    commentId++;
                    commentSortNo++;
                }

                categoryId++;
            }

            //全消し全書き
            CommentSpecification.DeleteAll();
            Comment.DeleteAll();
            CommentCategory.DeleteAll();
            CommentStandardRoom.DeleteAll();

            foreach (var category in categories)
            {
                category.Store();

                foreach (var comment in category.Comments)
                {
                    comment.Store();

                    foreach (var spec in comment.Specifications)
                    {
                        var commentSpec = new CommentSpecification();
                        commentSpec.CommentId       = comment.Id;
                        commentSpec.SpecificationId = spec.Id;
                        commentSpec.UpdatedDateTime = comment.UpdatedDateTime;

                        commentSpec.Store();
                    }

                    foreach (var roomName in comment.CommentStandardRooms)
                    {
                        var commentStadard = new CommentStandardRoom();
                        commentStadard.CommentId        = comment.Id;
                        commentStadard.StandardRoomName = roomName.StandardRoomName;
                        commentStadard.UpdatedDateTime  = comment.UpdatedDateTime;

                        commentStadard.Store();
                    }
                }
            }
        }