1
0
mirror of https://github.com/bitwarden/server synced 2025-12-11 22:03:38 +00:00

refactor for cipher details, folders, favorites

This commit is contained in:
Kyle Spearrin
2017-03-18 11:58:02 -04:00
parent 2b71420818
commit 588f6c7c2c
15 changed files with 139 additions and 138 deletions

View File

@@ -1,11 +1,12 @@
using System;
using Bit.Core.Models.Table;
using Core.Models.Data;
namespace Bit.Core.Models.Api
{
public class CipherResponseModel : ResponseModel
{
public CipherResponseModel(Cipher cipher, Guid userId, string obj = "cipher")
public CipherResponseModel(Cipher cipher, string obj = "cipher")
: base(obj)
{
if(cipher == null)
@@ -14,17 +15,33 @@ namespace Bit.Core.Models.Api
}
Id = cipher.Id.ToString();
FolderId = cipher.FolderId?.ToString();
Type = cipher.Type;
Favorite = cipher.Favorite;
RevisionDate = cipher.RevisionDate;
switch(cipher.Type)
{
case Core.Enums.CipherType.Folder:
Data = new FolderDataModel(cipher);
case Enums.CipherType.Login:
Data = new LoginDataModel(cipher);
break;
case Core.Enums.CipherType.Login:
default:
throw new ArgumentException("Unsupported " + nameof(Type) + ".");
}
}
public CipherResponseModel(CipherDetails cipher, string obj = "cipher")
: base(obj)
{
if(cipher == null)
{
throw new ArgumentNullException(nameof(cipher));
}
Id = cipher.Id.ToString();
Type = cipher.Type;
RevisionDate = cipher.RevisionDate;
switch(cipher.Type)
{
case Enums.CipherType.Login:
Data = new LoginDataModel(cipher);
break;
default:
@@ -34,7 +51,7 @@ namespace Bit.Core.Models.Api
public string Id { get; set; }
public string FolderId { get; set; }
public Core.Enums.CipherType Type { get; set; }
public Enums.CipherType Type { get; set; }
public bool Favorite { get; set; }
public dynamic Data { get; set; }
public DateTime RevisionDate { get; set; }