9 changed files with 124 additions and 71 deletions
@ -1,36 +0,0 @@
@@ -1,36 +0,0 @@
|
||||
namespace Bit.Api.Models |
||||
{ |
||||
public class CipherDataModel |
||||
{ |
||||
public CipherDataModel() { } |
||||
|
||||
public CipherDataModel(CipherRequestModel cipher) |
||||
{ |
||||
Name = cipher.Name; |
||||
Uri = cipher.Uri; |
||||
Username = cipher.Username; |
||||
Password = cipher.Password; |
||||
Notes = cipher.Notes; |
||||
} |
||||
|
||||
public CipherDataModel(SiteRequestModel site) |
||||
{ |
||||
Name = site.Name; |
||||
Uri = site.Uri; |
||||
Username = site.Username; |
||||
Password = site.Password; |
||||
Notes = site.Notes; |
||||
} |
||||
|
||||
public CipherDataModel(FolderRequestModel folder) |
||||
{ |
||||
Name = folder.Name; |
||||
} |
||||
|
||||
public string Name { get; set; } |
||||
public string Uri { get; set; } |
||||
public string Username { get; set; } |
||||
public string Password { get; set; } |
||||
public string Notes { get; set; } |
||||
} |
||||
} |
||||
@ -0,0 +1,35 @@
@@ -0,0 +1,35 @@
|
||||
using System; |
||||
using Bit.Core.Domains; |
||||
using Newtonsoft.Json; |
||||
|
||||
namespace Bit.Api.Models |
||||
{ |
||||
public class FolderDataModel |
||||
{ |
||||
public FolderDataModel() { } |
||||
|
||||
public FolderDataModel(FolderRequestModel folder) |
||||
{ |
||||
Name = folder.Name; |
||||
} |
||||
|
||||
public FolderDataModel(CipherRequestModel cipher) |
||||
{ |
||||
Name = cipher.Name; |
||||
} |
||||
|
||||
public FolderDataModel(Cipher cipher) |
||||
{ |
||||
if(cipher.Type != Core.Enums.CipherType.Folder) |
||||
{ |
||||
throw new ArgumentException("Cipher is not correct type."); |
||||
} |
||||
|
||||
var data = JsonConvert.DeserializeObject<FolderDataModel>(cipher.Data); |
||||
|
||||
Name = data.Name; |
||||
} |
||||
|
||||
public string Name { get; set; } |
||||
} |
||||
} |
||||
@ -0,0 +1,51 @@
@@ -0,0 +1,51 @@
|
||||
using System; |
||||
using Bit.Core.Domains; |
||||
using Newtonsoft.Json; |
||||
|
||||
namespace Bit.Api.Models |
||||
{ |
||||
public class SiteDataModel |
||||
{ |
||||
public SiteDataModel() { } |
||||
|
||||
public SiteDataModel(SiteRequestModel site) |
||||
{ |
||||
Name = site.Name; |
||||
Uri = site.Uri; |
||||
Username = site.Username; |
||||
Password = site.Password; |
||||
Notes = site.Notes; |
||||
} |
||||
|
||||
public SiteDataModel(CipherRequestModel cipher) |
||||
{ |
||||
Name = cipher.Name; |
||||
Uri = cipher.Uri; |
||||
Username = cipher.Username; |
||||
Password = cipher.Password; |
||||
Notes = cipher.Notes; |
||||
} |
||||
|
||||
public SiteDataModel(Cipher cipher) |
||||
{ |
||||
if(cipher.Type != Core.Enums.CipherType.Site) |
||||
{ |
||||
throw new ArgumentException("Cipher is not correct type."); |
||||
} |
||||
|
||||
var data = JsonConvert.DeserializeObject<SiteDataModel>(cipher.Data); |
||||
|
||||
Name = data.Name; |
||||
Uri = data.Uri; |
||||
Username = data.Username; |
||||
Password = data.Password; |
||||
Notes = data.Notes; |
||||
} |
||||
|
||||
public string Name { get; set; } |
||||
public string Uri { get; set; } |
||||
public string Username { get; set; } |
||||
public string Password { get; set; } |
||||
public string Notes { get; set; } |
||||
} |
||||
} |
||||
Loading…
Reference in new issue