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); } } }
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); }
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); }
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); }
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); } }
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); }
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); } } }
/// <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 })); }
/// <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(); }