2016-06-18 16:03:33 -04:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
2022-01-11 10:40:51 +01:00
|
|
|
|
using Bit.Core.Entities;
|
2016-06-18 16:03:33 -04:00
|
|
|
|
using Bit.Core.Enums;
|
|
|
|
|
|
|
2021-12-14 15:05:07 +00:00
|
|
|
|
namespace Bit.Api.Models.Request
|
2016-06-18 16:03:33 -04:00
|
|
|
|
{
|
|
|
|
|
|
public class DeviceRequestModel
|
|
|
|
|
|
{
|
|
|
|
|
|
[Required]
|
|
|
|
|
|
public DeviceType? Type { get; set; }
|
|
|
|
|
|
[Required]
|
|
|
|
|
|
[StringLength(50)]
|
|
|
|
|
|
public string Name { get; set; }
|
2016-06-21 00:08:22 -04:00
|
|
|
|
[Required]
|
|
|
|
|
|
[StringLength(50)]
|
|
|
|
|
|
public string Identifier { get; set; }
|
2016-06-18 16:03:33 -04:00
|
|
|
|
[StringLength(255)]
|
|
|
|
|
|
public string PushToken { get; set; }
|
|
|
|
|
|
|
2017-01-24 22:46:54 -05:00
|
|
|
|
public Device ToDevice(Guid? userId = null)
|
2016-06-18 16:03:33 -04:00
|
|
|
|
{
|
|
|
|
|
|
return ToDevice(new Device
|
|
|
|
|
|
{
|
2017-01-24 22:46:54 -05:00
|
|
|
|
UserId = userId == null ? default(Guid) : userId.Value
|
2016-06-18 16:03:33 -04:00
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Device ToDevice(Device existingDevice)
|
|
|
|
|
|
{
|
|
|
|
|
|
existingDevice.Name = Name;
|
2016-06-21 00:08:22 -04:00
|
|
|
|
existingDevice.Identifier = Identifier;
|
2016-06-18 16:03:33 -04:00
|
|
|
|
existingDevice.PushToken = PushToken;
|
|
|
|
|
|
existingDevice.Type = Type.Value;
|
|
|
|
|
|
|
|
|
|
|
|
return existingDevice;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2016-06-21 00:08:22 -04:00
|
|
|
|
|
|
|
|
|
|
public class DeviceTokenRequestModel
|
|
|
|
|
|
{
|
|
|
|
|
|
[StringLength(255)]
|
|
|
|
|
|
public string PushToken { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public Device ToDevice(Device existingDevice)
|
|
|
|
|
|
{
|
|
|
|
|
|
existingDevice.PushToken = PushToken;
|
|
|
|
|
|
return existingDevice;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2016-06-18 16:03:33 -04:00
|
|
|
|
}
|