mirror of
https://github.com/bitwarden/server
synced 2025-12-17 16:53:23 +00:00
Moved models and removed deuplicate error for username since we use emails as username as well.
This commit is contained in:
57
src/Api/Models/Request/SiteRequestModel.cs
Normal file
57
src/Api/Models/Request/SiteRequestModel.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Bit.Api.Utilities;
|
||||
using Bit.Core.Domains;
|
||||
|
||||
namespace Bit.Api.Models
|
||||
{
|
||||
public class SiteRequestModel
|
||||
{
|
||||
[StringLength(36)]
|
||||
public string FolderId { get; set; }
|
||||
[Required]
|
||||
[EncryptedString]
|
||||
[StringLength(300)]
|
||||
public string Name { get; set; }
|
||||
[Required]
|
||||
[EncryptedString]
|
||||
[StringLength(5000)]
|
||||
public string Uri { get; set; }
|
||||
[EncryptedString]
|
||||
[StringLength(200)]
|
||||
public string Username { get; set; }
|
||||
[Required]
|
||||
[EncryptedString]
|
||||
[StringLength(300)]
|
||||
public string Password { get; set; }
|
||||
[EncryptedString]
|
||||
[StringLength(5000)]
|
||||
public string Notes { get; set; }
|
||||
|
||||
public Site ToSite(string userId = null)
|
||||
{
|
||||
return new Site
|
||||
{
|
||||
UserId = userId,
|
||||
FolderId = string.IsNullOrWhiteSpace(FolderId) ? null : FolderId,
|
||||
Name = Name,
|
||||
Uri = Uri,
|
||||
Username = string.IsNullOrWhiteSpace(Username) ? null : Username,
|
||||
Password = Password,
|
||||
Notes = string.IsNullOrWhiteSpace(Notes) ? null : Notes
|
||||
};
|
||||
}
|
||||
|
||||
public Site ToSite(Site existingSite)
|
||||
{
|
||||
existingSite.FolderId = string.IsNullOrWhiteSpace(FolderId) ? null : FolderId;
|
||||
existingSite.Name = Name;
|
||||
existingSite.Uri = Uri;
|
||||
existingSite.Username = string.IsNullOrWhiteSpace(Username) ? null : Username;
|
||||
existingSite.Password = Password;
|
||||
existingSite.Notes = string.IsNullOrWhiteSpace(Notes) ? null : Notes;
|
||||
|
||||
return existingSite;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user