-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSaveBookmarkCommand.cs
35 lines (32 loc) · 1.01 KB
/
SaveBookmarkCommand.cs
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
28
29
30
31
32
33
34
35
using System;
using System.Linq;
using OrigoDB.Core;
namespace OrigoDb.Examples.GettingStarted
{
[Serializable]
public class SaveBookmarkCommand : Command<BookmarkModel>
{
public readonly string Url;
public readonly string Title;
public readonly DateTime Added;
private readonly string[] Tags;
public SaveBookmarkCommand(string url, string title, DateTime added, string[] tags)
{
Url = url;
Title = title;
Added = added;
Tags = tags.ToArray();
}
/// <summary>
/// Create a Bookmark object and add it to the model
/// </summary>
/// <param name="model">You have an exclusive lock on the model</param>
protected override void Execute(BookmarkModel model)
{
var bookmark = new Bookmark(Url, Title);
bookmark.Added = Added;
foreach (string tag in Tags) bookmark.Tags.Add(tag);
model.SaveBookmark(bookmark);
}
}
}