1
0
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:
Kyle Spearrin
2016-03-08 21:20:56 -05:00
parent 8b2186989f
commit 994f27ff40
6 changed files with 1 additions and 1 deletions

View 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;
}
}
}