collection and folder models

This commit is contained in:
Kyle Spearrin 2019-04-15 08:42:50 -04:00
parent eeb28f6ddf
commit 4b67ba027e
4 changed files with 102 additions and 7 deletions

View File

@ -0,0 +1,41 @@
using Bit.Core.Models.Data;
using Bit.Core.Models.View;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Bit.Core.Models.Domain
{
public class Collection : Domain
{
public Collection() { }
public Collection(CollectionData obj, bool alreadyEncrypted = false)
{
BuildDomainModel(this, obj, new HashSet<string>
{
"Id",
"OrganizationId",
"Name",
"ExternalId",
"ReadOnly"
}, alreadyEncrypted, new HashSet<string>
{
"Id",
"OrganizationId",
"ExternalId",
"ReadOnly"
});
}
public string Id { get; set; }
public string OrganizationId { get; set; }
public CipherString Name { get; set; }
public string ExternalId { get; set; }
public bool ReadOnly { get; set; }
public Task<CollectionView> DecryptAsync(string orgId)
{
return DecryptObjAsync(new CollectionView(this), this, new HashSet<string> { "Name" }, orgId);
}
}
}

View File

@ -0,0 +1,32 @@
using Bit.Core.Models.Data;
using Bit.Core.Models.View;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Bit.Core.Models.Domain
{
public class Folder : Domain
{
public Folder() { }
public Folder(FolderData obj, bool alreadyEncrypted = false)
{
BuildDomainModel(this, obj, new HashSet<string>
{
"Id",
"Name"
}, alreadyEncrypted, new HashSet<string> { "Id" });
RevisionDate = obj.RevisionDate;
}
public string Id { get; set; }
public CipherString Name { get; set; }
public DateTime RevisionDate { get; set; }
public Task<FolderView> DecryptAsync(string orgId)
{
return DecryptObjAsync(new FolderView(this), this, new HashSet<string> { "Name" }, orgId);
}
}
}

View File

@ -1,10 +1,23 @@
using System;
using Bit.Core.Models.Domain;
namespace Bit.Core.Models.View
{
public class CollectionView
public class CollectionView : View
{
public Guid OrganizationId { get; set; }
public CollectionView() { }
public CollectionView(Collection c)
{
Id = c.Id;
OrganizationId = c.OrganizationId;
ReadOnly = c.ReadOnly;
ExternalId = c.ExternalId;
}
public string Id { get; set; }
public string OrganizationId { get; set; }
public string Name { get; set; }
public string ExternalId { get; set; }
public bool ReadOnly { get; set; }
}
}

View File

@ -1,11 +1,20 @@
using System;
using System.Collections.Generic;
using System.Text;
using Bit.Core.Models.Domain;
using System;
namespace Bit.Core.Models.View
{
public class FolderView
public class FolderView : View
{
public FolderView() { }
public FolderView(Folder f)
{
Id = f.Id;
RevisionDate = f.RevisionDate;
}
public string Id { get; set; }
public string Name { get; set; }
public DateTime RevisionDate { get; set; }
}
}