summaryrefslogtreecommitdiffstats
path: root/src/server/Api/V1/Entries/CreateEntryRequest.cs
blob: a9c5070ca6ca0d89921e01efe70501347e4c62e3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
namespace IOL.BookmarkThing.Server.Api.V1.Entries;

public class CreateEntryRequest
{
	public Uri Url { get; set; }
	public string Description { get; set; }
	public string Tags { get; set; }

	public List<ErrorResult> GetErrors() {
		var errors = new List<ErrorResult>();
		if (Url == default) {
			errors.Add(new ErrorResult("Url is a required field"));
		}

		return errors;
	}

	public Entry AsDbEntity(Guid userId) {
		return new Entry {
				Id = Guid.NewGuid(),
				UserId = userId,
				Url = Url,
				Description = Description,
				Tags = Tags
		};
	}
}