/// <summary> /// Add a user to the database /// </summary> /// <param name="owner">The user to add</param> public static bool AddUser(Owner owner) { try { using (var context = new OOADEntities()) { user u = new user(); u.name = owner.Name; context.users.AddObject(u); context.SaveChanges(); return true; } } catch (Exception) { return false; } }
/// <summary> /// Add a LogEntry to the database /// </summary> /// <param name="entry">The LogEntry to add</param> public static bool AddLogEntry(LogEntry entry) { using (var context = new OOADEntities()) { logEntry dbEntry = new logEntry(); dbEntry.jobId = entry.JobId; dbEntry.state = entry.State.ToString(); dbEntry.timeStamp = entry.TimeStamp; //If the user doesn't exist in the db, we'll get a NPE try { dbEntry.userId = entry.JobOwner.Id; } catch (NullReferenceException) { return false; } context.logEntries.AddObject(dbEntry); context.SaveChanges(); return true; } }