public virtual void NewDownload(string name, string email, string downloadType, string fileName) { IOdb odb = null; User user = null; try { odb = Open("download.ndb"); var query = odb.Query<User>(); query.Descend("email").Constrain((object) email).Equal(); var users = query.Execute<User>(); if (users.Count != 0) { user = users.GetFirst(); user.SetLastDownload(new DateTime()); user.SetNbDownloads(user.GetNbDownloads() + 1); odb.Store(user); } else { user = new User(); user.SetName(name); user.SetEmail(email); user.SetLastDownload(new DateTime()); user.SetNbDownloads(1); odb.Store(user); } var download = new Download(); download.SetFileName(fileName); download.SetType(downloadType); download.SetUser(user); download.SetWhen(new DateTime()); odb.Store(download); } finally { if (odb != null) odb.Close(); } }
public virtual void SetUser(User user) { this.user = user; }