1
0
mirror of https://github.com/bitwarden/server synced 2025-12-13 14:53:34 +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

@@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations;
using Bit.Core.Utilities;
using Bit.Core.Models.Table;
using Newtonsoft.Json;
using Core.Models.Data;
namespace Bit.Core.Models.Api
{
@@ -28,21 +29,22 @@ namespace Bit.Core.Models.Api
[StringLength(10000)]
public string Notes { get; set; }
public Cipher ToCipher(Guid userId)
public CipherDetails ToCipher(Guid userId)
{
return ToCipher(new Cipher
return ToCipher(new CipherDetails
{
UserId = userId
});
}
public Cipher ToCipher(Cipher existingLogin)
public CipherDetails ToCipher(CipherDetails existingLogin)
{
existingLogin.FolderId = string.IsNullOrWhiteSpace(FolderId) ? null : (Guid?)new Guid(FolderId);
existingLogin.Favorite = Favorite;
existingLogin.Data = JsonConvert.SerializeObject(new LoginDataModel(this),
new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
existingLogin.Type = Core.Enums.CipherType.Login;
existingLogin.Type = Enums.CipherType.Login;
return existingLogin;
}