Files
server/src/Core/Models/Api/SecureNoteDataModel.cs
2017-09-21 10:52:23 -04:00

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; }
}
}