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

36 lines
957 B
C#
Raw Normal View History

2017-03-07 23:06:14 -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;
2017-03-07 23:06:14 -05:00
using Newtonsoft.Json;
using System.Collections.Generic;
2017-03-07 23:06:14 -05:00
2017-03-08 21:55:08 -05:00
namespace Bit.Core.Models.Api
2017-03-07 23:06:14 -05:00
{
2017-04-27 09:19:30 -04:00
public class CollectionRequestModel
2017-03-07 23:06:14 -05:00
{
2017-03-09 22:09:09 -05:00
[Required]
[EncryptedString]
2018-08-02 08:57:32 -04:00
[EncryptedStringLength(1000)]
2017-03-09 22:09:09 -05:00
public string Name { get; set; }
2019-03-07 15:18:27 -05:00
[StringLength(300)]
public string ExternalId { get; set; }
2017-05-11 12:22:14 -04:00
public IEnumerable<SelectionReadOnlyRequestModel> Groups { get; set; }
2017-03-07 23:06:14 -05:00
2017-04-27 09:19:30 -04:00
public Collection ToCollection(Guid orgId)
2017-03-07 23:06:14 -05:00
{
2017-04-27 09:19:30 -04:00
return ToCollection(new Collection
2017-03-07 23:06:14 -05:00
{
2017-03-09 22:09:09 -05:00
OrganizationId = orgId
2017-03-07 23:06:14 -05:00
});
}
2017-04-27 09:19:30 -04:00
public Collection ToCollection(Collection existingCollection)
2017-03-07 23:06:14 -05:00
{
2017-04-27 09:19:30 -04:00
existingCollection.Name = Name;
2019-03-07 15:18:27 -05:00
existingCollection.ExternalId = ExternalId;
2017-04-27 09:19:30 -04:00
return existingCollection;
2017-03-07 23:06:14 -05:00
}
}
}