public void Add(Task task) { var model = TaskModel.FromRepositoryType(task, _computers, _scripts, _users); _tasks.Add(model); _save(); task.SetId(model.Id); }
public Task ToRepositoryType() { var result = new Task( expiration: Expiration, id: Id, origin: Origin, owner: Owner.ToRepositoryType(), receivedTimestamp: ReceivedTimestamp, script: Script.ToRepositoryType(), target: Target.ToRepositoryType() ); return result; }
public static TaskModel FromRepositoryType(Task model, DbSet<ComputerModel> computers,DbSet<ScriptModel> scripts, DbSet<UserModel> users) { var result = new TaskModel { Expiration = model.Expiration, Id = model.Id, Origin = model.Origin, Owner = users.Find(model.Owner.Id), ReceivedTimestamp = model.ReceivedTimestamp, Script = scripts.Find(model.Script.Id), Target = computers.Find(model.Target.Id) }; return result; }
private Task GetSerializableVersion(Task task) { User owner = null; if (task.Owner != null) { owner = new User( alias: task.Owner.Alias, email: null, id: task.Owner.Id, registeredTimestamp: null, secret: null, token: null ); } Computer target = null; if (task.Target != null) { target = new Computer( accessKey: null, address: null, encryptionKey: null, id: task.Target.Id, lastPing: null, lastScript: null, name: task.Target.Name, owner: null ); } var result = new Task( expiration: task.Expiration, id: task.Id, origin: task.Origin, owner: owner, receivedTimestamp: task.ReceivedTimestamp, script: task.Script, target: target ); return result; }
public static Task Create(User owner, string origin, Computer target, Script script) { var result = new Task { Expiration = DateTime.UtcNow.AddSeconds(30), Origin = origin, Owner = owner, Script = script, Target = target }; return result; }
public void Update(Task task) { var model = _tasks.Find(task.Id); model.ReceivedTimestamp = task.ReceivedTimestamp; _save(); }
public void Remove(Task task) { var model = _tasks.Find(task.Id); _tasks.Remove(model); _save(); }