public object Post(QB_Time request) { ApiUser hdUser = request.ApiUser; Instance_Config instanceConfig = new Instance_Config(hdUser); CheckQBOnlineIntegration(instanceConfig); bool isProjectLog = false; string notes = ""; int qb_employee_id = 0; int qb_vendor_id = 0; DateTime date = DateTime.Now; if (request.is_project_log.HasValue) { isProjectLog = request.is_project_log.Value; } if (request.qb_employee_id.HasValue) { qb_employee_id = request.qb_employee_id.Value; } if (request.qb_vendor_id.HasValue) { qb_vendor_id = request.qb_vendor_id.Value; } if (request.notes != null) { notes = request.notes; } if (request.date.HasValue) { date = request.date.Value; } decimal time_offset = hdUser.TimeZoneOffset; if (request.time_offset.HasValue) { time_offset = request.time_offset.Value; } bool is_billable = request.is_billable ?? true; bool is_rate_fixed = request.is_rate_fixed ?? false; try { string result = QBTimeActivities.CreateTimeActivity(hdUser, instanceConfig, qb_employee_id, request.qb_customer_id, request.qb_service_id, request.hours, request.hourly_rate, notes, date, request.time_id, isProjectLog, is_billable, request.start_time, request.stop_time, time_offset, 0, -1, false, qb_vendor_id, is_rate_fixed); if (result == "ok") { return(new HttpResult("", HttpStatusCode.OK)); } else { throw new HttpError(Utils.ClearString(result)); } } catch (Exception ex) { throw new HttpError(Utils.ClearString(ex.Message)); } }
public object Delete(QB_Time_Delete request) { ApiUser hdUser = request.ApiUser; Instance_Config instanceConfig = new Instance_Config(hdUser); CheckQBOnlineIntegration(instanceConfig); bool isProjectLog = false; if (request.is_project_log.HasValue) { isProjectLog = request.is_project_log.Value; } if (request.is_unlink) { try { QBTimeActivities.UnlinkQuickBooksTimeActivity(hdUser, request.key, isProjectLog); return(new HttpResult("", HttpStatusCode.OK)); } catch (Exception ex) { throw new HttpError(Utils.ClearString(ex.Message)); } } else { try { QBTimeActivities.DeleteQuickBooksTimeActivity(hdUser, instanceConfig, request.key, isProjectLog); return(new HttpResult("", HttpStatusCode.OK)); } catch (Exception ex) { throw new HttpError(Utils.ClearString(ex.Message)); } } }