コード例 #1
0
        public ActionResult PostsEdit(int id)
        {
            using (var db = new DBContext())
            {
                PostEditTake model = new PostEditTake
                {
                    Post = db.Posts.FirstOrDefault(ok => ok.ID == id)
                };

                model.Labels = new List <label>();
                foreach (var item in db.Labels.Where(ok => ok.Post_ID == id))
                {
                    model.Labels.Add(new label
                    {
                        key   = item.Label,
                        value = item.LabelTypes_ID
                    });
                }

                model.Post.Label = null;
                return(Json(model, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #2
0
        public ActionResult PostsEdit(int id)
        {
            using (UnitOfWork work = new UnitOfWork())
            {
                PostEditTake model = new PostEditTake
                {
                    Post = work.PostsRepository.findById(id)
                };

                model.Labels = new List <label>();
                foreach (var item in work.LabelsRepository.listByWhere(ok => ok.Post_ID == id))
                {
                    model.Labels.Add(new label
                    {
                        key   = item.Label,
                        value = item.LabelTypes_ID
                    });
                }

                model.Post.Label = null;
                return(Json(model, JsonRequestBehavior.AllowGet));
            }
        }