public string GetQuickbooksTimesheet(DateTime fromDate, DateTime toDate, string username) { // Get the data var timeEntries = _db.GetQuickbooksTimeEntries(fromDate, toDate); // Build the file var sb = new StringBuilder(); sb.AppendLine("!TIMEACT DATE JOB EMP ITEM DURATION NOTE BILLINGSTATUS"); foreach (var entry in timeEntries) { // Get the data for the actual user entering in the data var userInformation = _db.GetUser(entry.CreatedBy); // Just move to the next record, if there isn't a name for export if (userInformation.Profile == null) { continue; } // Set the name to use for the export var userQuickbooksName = userInformation.Profile.FullName; // Add an entry sb.AppendFormat("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}\r\n", "TIMEACT", entry.DateWorked.ToString("MM/dd/yyyy"), entry.Project.QuickbooksProjectId, userQuickbooksName, "Programming - Standard", entry.TotalTime.ToString(), entry.Description, entry.IsBillable ? "1" : "0"); } return(sb.ToString()); }
/// <summary> /// Adds the client. /// </summary> /// <param name="newClient">The new client.</param> /// <param name="username">The username.</param> /// <returns>IOpResult.</returns> public IOpResult AddClient(Client newClient, string username) { var userEntity = _db.GetUser(username); if (userEntity == null) { throw new ArgumentException(Resources.InvalidUserIdMessage); } newClient.UserId = userEntity.UserId; return(_db.AddClient(newClient)); }
/// <summary> /// Adds the time entry. /// </summary> /// <param name="entry">The entry.</param> /// <param name="username">The username.</param> /// <returns>IOpResult.</returns> public IOpResult AddTimeEntry(TimeEntry entry, string username) { // Get the User Id var userEntity = _db.GetUser(username); if (userEntity == null) { throw new ArgumentException(Resources.InvalidUserIdMessage); } entry.UserId = userEntity.UserId; entry.CreatedBy = username; entry.CreatedAt = DateTime.Now; return(_db.AddTimeEntry(entry, username)); }
/// <summary> /// Gets the user. /// </summary> /// <param name="userName">Name of the user.</param> /// <returns>User.</returns> public User GetUser(string userName) { return(_db.GetUser(userName)); }