Files
server/src/Core/Models/Api/Request/FolderRequestModel.cs

33 lines
845 B
C#
Raw Normal View History

2015-12-08 22:57:38 -05:00
using System;
using System.ComponentModel.DataAnnotations;
2017-03-08 21:55:08 -05:00
using Bit.Core.Utilities;
2017-03-08 21:45:08 -05:00
using Bit.Core.Models.Table;
using Newtonsoft.Json;
2015-12-08 22:57:38 -05:00
2017-03-08 21:55:08 -05:00
namespace Bit.Core.Models.Api
2015-12-08 22:57:38 -05:00
{
public class FolderRequestModel
{
[Required]
[EncryptedString]
[StringLength(300)]
2015-12-08 22:57:38 -05:00
public string Name { get; set; }
public Cipher ToCipher(Guid userId)
2015-12-08 22:57:38 -05:00
{
return ToCipher(new Cipher
2015-12-08 22:57:38 -05:00
{
UserId = userId
});
2015-12-08 22:57:38 -05:00
}
public Cipher ToCipher(Cipher existingFolder)
2015-12-08 22:57:38 -05:00
{
existingFolder.Data = JsonConvert.SerializeObject(new FolderDataModel(this), new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
existingFolder.Type = Core.Enums.CipherType.Folder;
2015-12-08 22:57:38 -05:00
return existingFolder;
}
}
}