コード例 #1
0
        public void Test_RelationUpdate_01()
        {
            _logger.Trace(">>> Labelモデルの読み込みテストを開始");
            using (InitializeFact())
            {
                {
                    var @dbc   = (AppDbContext)container.GetInstance <IAppDbContext>();
                    var repo   = new LabelRepository(dbc);
                    var repoc  = new ContentRepository(dbc);
                    var entity = repo.Load(2L);

                    var content = repoc.Load(2L);
                    entity.Contents.Add(new Model.Label2Content
                    {
                        Content = (Content)content,
                        Label   = entity
                    });

                    repo.Save();
                }

                {
                    var @dbc   = (AppDbContext)container.GetInstance <IAppDbContext>();
                    var repo   = new LabelRepository(dbc);
                    var entity = repo.Load(2L);
                    Assert.Equal(entity.Contents[1].Content.Id, 2L);
                }
            }
        }
コード例 #2
0
        private SVP.CIL.Domain.Label LabelRead(AppDbContext dbc, SVP.CIL.Domain.Label target)
        {
            var repo        = new LabelRepository(dbc);
            var label       = repo.Load(target.Id);
            var domainLabel = Mapper.Map <SVP.CIL.Domain.Label>(label);

            return(domainLabel);
        }
コード例 #3
0
        private bool LabelDelete(AppDbContext dbc, SVP.CIL.Domain.Label target)
        {
            var repo  = new LabelRepository(dbc);
            var label = repo.Load(target.Id);

            repo.Delete(label);
            dbc.SaveChanges();
            return(true);
        }
コード例 #4
0
        private SVP.CIL.Domain.Label LabelUpdate(AppDbContext dbc, SVP.CIL.Domain.Label target)
        {
            var repo  = new LabelRepository(dbc);
            var label = repo.Load(target.Id);

            Mapper.Map <SVP.CIL.Domain.Label, Label>(target, label);
            repo.Save();
            dbc.SaveChanges();
            var domainLabel = Mapper.Map <SVP.CIL.Domain.Label>(label);

            return(domainLabel);
        }
コード例 #5
0
        public void Test_Load_01()
        {
            _logger.Trace(">>> Labelモデルの読み込みテストを開始");
            using (InitializeFact())
            {
                var @dbc   = (AppDbContext)container.GetInstance <IAppDbContext>();
                var repo   = new LabelRepository(dbc);
                var entity = repo.Load(2L);
                Assert.Equal(entity.Name, "テストラベル_2");

                Assert.Equal(entity.Category.Id, 1L);
                Assert.Equal(entity.Category.Name, "ROOT");
                Assert.Equal(entity.Contents[0].Content.Id, 1L);
            }
        }
コード例 #6
0
        public ResponseLabelLoadList LabelLoadList(RequestLabelLoadList reqparam)
        {
            var resp = new ResponseLabelLoadList();

            try
            {
                using (var dbc = new AppDbContext())
                {
                    var repo = new LabelRepository(dbc);
                    resp.Datas = new List <SVP.CIL.Domain.Label>();

                    if (reqparam.ParentTarget != null)
                    {
                        var label = repo.Load(reqparam.ParentTarget.Id);

                        foreach (var c in label.ChildLabels)
                        {
                            var domainLabel = Mapper.Map <SVP.CIL.Domain.Label>(c);
                            resp.Datas.Add(domainLabel);
                        }
                    }
                    else
                    {
                        foreach (var c in repo.FindFloatLabel())
                        {
                            var domainLabel = Mapper.Map <SVP.CIL.Domain.Label>(c);
                            resp.Datas.Add(domainLabel);
                        }
                    }

                    resp.Success = true;
                }
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (DbEntityValidationResult entityErr in dbEx.EntityValidationErrors)
                {
                    foreach (DbValidationError error in entityErr.ValidationErrors)
                    {
                        Console.WriteLine("Error Property Name {0} : Error Message: {1}",
                                          error.PropertyName, error.ErrorMessage);
                        resp.Success = false;
                    }
                }
            }

            return(resp);
        }
コード例 #7
0
 public void Test_Update_01()
 {
     _logger.Trace(">>> Labelモデルの読み込みテストを開始");
     using (InitializeFact())
     {
         string updateName = "POTEST";
         {
             var @dbc   = (AppDbContext)container.GetInstance <IAppDbContext>();
             var repo   = new LabelRepository(dbc);
             var entity = repo.Load(2L);
             entity.Name = updateName;
             repo.Save();
         }
         {
             var @dbc   = (AppDbContext)container.GetInstance <IAppDbContext>();
             var repo   = new LabelRepository(dbc);
             var entity = repo.Load(2L);
             Assert.Equal(entity.Name, updateName);
         }
     }
 }
コード例 #8
0
        /// <summary>
        /// obtains the tag detail
        /// </summary>
        /// <param name="id">identifier of tag</param>
        /// <returns>returns the result to action</returns>
        public ActionResult Detail(int?id)
        {
            LabelRepository objlab = new LabelRepository(SessionCustom);

            Domain.Entities.Label lab = null;

            if (id != null)
            {
                objlab.Entity.LabelId = id;
                objlab.Load();
                lab        = objlab.Entity;
                ViewBag.id = id;
            }

            return(this.View(new Labels()
            {
                UserPrincipal = CustomUser,
                Module = this.Module,
                LabelCustom = lab,
                ColModul = CustomMemberShipProvider.GetModuls(CustomUser.UserId, SessionCustom, HttpContext),
                CurrentLanguage = CurrentLanguage
            }));
        }
コード例 #9
0
ファイル: EntityTestBase.cs プロジェクト: pixstock-p/pixstock
        /// <summary>
        /// InMemoryデータベース用のユニットテストデータを作成する
        /// </summary>
        void ImportInitializeData(int threadId, SimpleInjector.Container container)
        {
            var @dbc = (AppDbContext)container.GetInstance <IAppDbContext>();

            // Category
            var repo_Category = new CategoryRepository(@dbc);

            repo_Category.Add(new Category
            {
                Id   = 2,
                Name = "テストカテゴリA"
            });
            repo_Category.Add(new Category
            {
                Id   = 3,
                Name = "テストカテゴリA2"
            });
            repo_Category.Add(new Category
            {
                Id   = 4,
                Name = "テストカテゴリA3"
            });

            // Label
            var repo_Label = new LabelRepository(@dbc);

            repo_Label.Add(new Label
            {
                Id   = 1,
                Name = "テストラベル"
            });
            repo_Label.Add(new Label
            {
                Id       = 2,
                Name     = "テストラベル_2",
                Category = (Category)repo_Category.Load(1)
            });

            // Content
            var repo_Content = new ContentRepository(@dbc);

            repo_Content.Add(new Content
            {
                Id          = 1,
                Name        = "Content1",
                IdentifyKey = "IDEN_Content1"
            });
            repo_Content.Add(new Content
            {
                Id          = 2,
                Name        = "Content2",
                IdentifyKey = "IDEN_Content2",
            });
            repo_Content.Add(new Content
            {
                Id          = 3,
                Name        = "Content3",
                IdentifyKey = "IDEN_Content3"
            });

            // Workspace
            var repo_Workspace = new WorkspaceRepository(@dbc);
            var workspace1     = new Workspace
            {
                Id           = 1,
                Name         = "UT_Workspace",
                PhysicalPath = Path.Combine(TESTDATADIRECTORY, "PixstockSrvUT_" + threadId)
            };

            repo_Workspace.Add(workspace1);

            // FileMappingInfo
            var repo_FileMappingInfo = new FileMappingInfoRepository(@dbc);

            repo_FileMappingInfo.Add(new FileMappingInfo
            {
                Id        = 1,
                AclHash   = "ABC1",
                Workspace = workspace1
            });

            @dbc.SaveChanges();

            var label2 = repo_Label.Load(2L);

            label2.Contents.Add(new Label2Content
            {
                ContentId = 1L,
                Content   = (Content)repo_Content.Load(1L),
                LabelId   = 2L,
                Label     = label2
            });

            @dbc.SaveChanges();
        }