1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-22 21:45:15 -05:00
bitwarden/src/Api/Models/Request/FolderRequestModel.cs

33 lines
853 B
C#

using System;
using System.ComponentModel.DataAnnotations;
using Bit.Api.Utilities;
using Bit.Core.Domains;
using Newtonsoft.Json;
namespace Bit.Api.Models
{
public class FolderRequestModel
{
[Required]
[EncryptedString]
[StringLength(300)]
public string Name { get; set; }
public Cipher ToCipher(string userId = null)
{
return ToCipher(new Cipher
{
UserId = new Guid(userId)
});
}
public Cipher ToCipher(Cipher existingFolder)
{
existingFolder.Data = JsonConvert.SerializeObject(new FolderDataModel(this), new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
existingFolder.Type = Core.Enums.CipherType.Folder;
return existingFolder;
}
}
}