public object Get(GET_Time_Logs request) { var query = base.Request.QueryString; return(base.RequestContext.ToOptimizedResultUsingCache(base.Cache, string.Format("urn:{0}:{1}{2}", base.Request.GetBasicAuth(), base.Request.PathInfo.Substring(1), (query.Count > 0 ? ":" + query.ToString() : "")), new System.TimeSpan(0, 1, 0), () => { return GetTimeLogs(request); })); }
private object GetTimeLogs(GET_Time_Logs request) { ApiUser hdUser = request.ApiUser; //v2 if (request.project_time_id > 0) { DataRow plRow = bigWebApps.bigWebDesk.Data.Project.SelectProjectTimeByID(hdUser.OrganizationId, hdUser.DepartmentId, request.project_time_id); if (plRow == null) { throw new HttpError(HttpStatusCode.NotFound, "No data found"); } return(new ProjectTimeLog(plRow)); } else if (request.ticket_time_id > 0) { DataRow tlRow = bigWebApps.bigWebDesk.Data.Tickets.SelectTicketTimeByID(hdUser.OrganizationId, hdUser.DepartmentId, request.ticket_time_id); if (tlRow == null) { throw new HttpError(HttpStatusCode.NotFound, "No data found"); } return(new Ticket_Time_Log(tlRow)); } if (!string.IsNullOrEmpty(request.ticket)) { return(request.FilteredResult <Ticket_Time_Log>(TicketTimeLogs.GetTicketTimeLogs(hdUser.OrganizationId, hdUser.DepartmentId, Ticket.GetId(hdUser.OrganizationId, hdUser.DepartmentId, request.ticket)))); } int accountID = request.account ?? 0; int projectID = request.project ?? 0; int techID = request.tech ?? 0; string type = string.IsNullOrEmpty(request.type) ? "recent" : request.type.ToLower(); if ((string.IsNullOrEmpty(request.type) || type == "tickets") && request.project.HasValue) { if (projectID == 0) { projectID = -2; } if (!request.account.HasValue) { accountID = -2; } if (projectID > 0 && accountID < 0) { ProjectDetail projectDetail = Models.Projects.GetProjectDetails(hdUser.OrganizationId, hdUser.DepartmentId, projectID); accountID = projectDetail.AccountId; } if (type == "tickets") { return(request.FilteredResult <Ticket_Time_Log>(Models.ProjectTicketTimeLogs.GetProjectTicketTimeLogs(hdUser.OrganizationId, hdUser.DepartmentId, projectID, accountID, techID, request.task_type_id, hdUser.TimeZoneOffset))); } return(request.FilteredResult <ProjectTimeLog>(Models.ProjectTimeLogs.GetProjectTimeLog(hdUser.OrganizationId, hdUser.DepartmentId, projectID, accountID, techID, request.task_type_id))); } if (type == "recent" || type == "linked_fb" || type == "unlinked_fb" || type == "invoiced" || type == "not_invoiced" || type == "unlinked_fb_billable" || type == "not_invoiced_billable" || type == "not_invoiced_nonbillable" || type == "linked_qb" || type == "unlinked_qb" || type == "unlinked_qb_billable" || type == "hidden_from_invoice" || type == "no_ticket_assigned") { return(request.SortedResult <CommonTimeLog>(Models.CommonTimeLogs.GetCommonTimeLog(hdUser.OrganizationId, hdUser.DepartmentId, type, accountID, projectID, techID, request.start_date, request.end_date, hdUser.TimeZoneId))); } throw new HttpError(HttpStatusCode.NotFound, "Incorrect time type"); }