Adding a TimeActivity Record

Adding a TimeActivity Record C#.NET Code

Adding a TimeActivity Record C#.NET Code
                    
DataService commonService = new DataService(serviceContext);
string displayName = "Test Customer";
displayName = displayName.Replace("'", "\\'"); //Escape special characters
QueryService customerQueryServiceXX = new QueryService(serviceContext);
Customer resultCustomer = customerQueryServiceXX.Where(m => m.DisplayName == displayName).FirstOrDefault();

string employeeName = "First Last";
employeeName = employeeName.Replace("'", "\\'"); //Escape special characters
QueryService customerQueryServiceEE = new QueryService(serviceContext);
Employee resultEmployee = customerQueryServiceEE.Where(m => m.DisplayName == employeeName).FirstOrDefault();

TimeActivity timeActivity = new TimeActivity();
timeActivity.BillableStatus = BillableStatusEnum.Billable;
timeActivity.BillableStatusSpecified = true;
timeActivity.Hours = 8;
timeActivity.Minutes = 0;
timeActivity.TxnDate = DateTime.Now.Date;
timeActivity.TxnDateSpecified = true;


timeActivity.NameOf = TimeActivityTypeEnum.Employee;
timeActivity.NameOfSpecified = true;
timeActivity.ItemElementName = ItemChoiceType5.EmployeeRef;    
timeActivity.AnyIntuitObject= new ReferenceType()
{
    name = resultEmployee.DisplayName,
    Value = resultEmployee.Id,
};

timeActivity.Description = "Did something";
TimeActivity timeActivityResult = commonService.Add(timeActivity);