public WorkRequestMetadataDTO SaveWorkRequest(WorkRequestMetadataDTO wr, string auth0Id) { WorkRequest newWorkRequest = null; wr.Person.EmployeeId = EmpRepository.GetEmployeeByAuthId(auth0Id).EmployeeId; if (wr.WorkRequestId != Guid.Empty) { newWorkRequest = DbContext.WorkRequests.Find(wr.WorkRequestId); } if (newWorkRequest != null) // Edit existing { newWorkRequest.ApproverId = wr.Approver.EmployeeId; newWorkRequest.EndTime = wr.EndTime != null ? wr.EndTime.Value : newWorkRequest.EndTime; newWorkRequest.OfficeId = wr.Office.OfficeId; newWorkRequest.PersonId = wr.Person.EmployeeId; newWorkRequest.RequestorId = wr.Requestor.EmployeeId; newWorkRequest.SectionId = wr.Section.SectionId; newWorkRequest.StartTime = wr.StartTime != null ? wr.StartTime.Value : newWorkRequest.StartTime; } else // Create new request { newWorkRequest = WorkRequestMetadataDTO.MapToBaseFunc(wr); newWorkRequest.WorkRequestId = Guid.NewGuid(); DbContext.Add(newWorkRequest); } DbContext.SaveChanges(); return(WorkRequestMetadataDTO.MapToDTOFunc(newWorkRequest)); }
public async ValueTask <WorkRequestMetadataDTO> GetWorkRequestById(Guid WorkRequestId) { var workRequest = await DbContext.WorkRequests.FindAsync(WorkRequestId); return(WorkRequestMetadataDTO.MapToDTOFunc(workRequest)); }
public WorkRequestMetadataDTO DenyWorkRequest(WorkRequestApprovalDTO wra, string auth0Id) { WorkRequest wr = SetStatusAndApprover(ApprovalStatusMetadataDTO._DENIED, wra, auth0Id); return(WorkRequestMetadataDTO.MapToDTOFunc(wr)); }