1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-02 00:22:50 -05:00

refactored data storage to use cipher table. added history table and insert triggers.

This commit is contained in:
Kyle Spearrin
2016-05-21 17:16:22 -04:00
parent 8137847485
commit 3fdb0fcf67
56 changed files with 422 additions and 646 deletions

View File

@ -2,6 +2,7 @@
using System.ComponentModel.DataAnnotations;
using Bit.Api.Utilities;
using Bit.Core.Domains;
using Newtonsoft.Json;
namespace Bit.Api.Models
{
@ -12,18 +13,20 @@ namespace Bit.Api.Models
[StringLength(300)]
public string Name { get; set; }
public Folder ToFolder(string userId = null)
public Cipher ToCipher(string userId = null)
{
return new Folder
return new Cipher
{
UserId = userId,
Name = Name
UserId = new Guid(userId),
Data = JsonConvert.SerializeObject(new CipherDataModel(this), new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }),
Type = Core.Enums.CipherType.Folder
};
}
public Folder ToFolder(Folder existingFolder)
public Cipher ToCipher(Cipher existingFolder)
{
existingFolder.Name = Name;
existingFolder.Data = JsonConvert.SerializeObject(new CipherDataModel(this), new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
existingFolder.Type = Core.Enums.CipherType.Folder;
return existingFolder;
}