mirror of
https://github.com/bitwarden/server.git
synced 2026-02-13 04:13:42 +08:00
40 lines
958 B
C#
40 lines
958 B
C#
using System;
|
|
using Bit.Core.Enums;
|
|
using Bit.Core.Models.Table;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace Bit.Core.Models.Api
|
|
{
|
|
public class SecureNoteDataModel : CipherDataModel
|
|
{
|
|
public SecureNoteDataModel() { }
|
|
|
|
public SecureNoteDataModel(CipherRequestModel cipher)
|
|
{
|
|
Name = cipher.Name;
|
|
Notes = cipher.Notes;
|
|
Fields = cipher.Fields;
|
|
|
|
Type = cipher.SecureNote.Type;
|
|
}
|
|
|
|
public SecureNoteDataModel(Cipher cipher)
|
|
{
|
|
if(cipher.Type != CipherType.SecureNote)
|
|
{
|
|
throw new ArgumentException("Cipher is not correct type.");
|
|
}
|
|
|
|
var data = JsonConvert.DeserializeObject<SecureNoteDataModel>(cipher.Data);
|
|
|
|
Name = data.Name;
|
|
Notes = data.Notes;
|
|
Fields = data.Fields;
|
|
|
|
Type = data.Type;
|
|
}
|
|
|
|
public SecureNoteType Type { get; set; }
|
|
}
|
|
}
|