public IQueryable <WorkRequestDetailDTO> GetWorkRequestDetailDTOs() { return(from request in DbContext.WorkRequests join capacity in DbContext.vWorkRequestCapacities on request.WorkRequestId equals capacity.WorkRequestId select new WorkRequestDetailDTO { Section = SectionMetadataDTO.MapToDTOFunc(request.Section), ApprovalStatus = new ApprovalStatusMetadataDTO { ApprovalStatusId = request.ApprovalStatus.ApprovalStatusId, IsFinal = request.ApprovalStatus.IsFinal, StatusName = request.ApprovalStatus.StatusName }, Approver = EmployeeMetadataDTO.MapToDTOFunc(request.Approver), Person = EmployeeMetadataDTO.MapToDTOFunc(request.Person), Requestor = EmployeeMetadataDTO.MapToDTOFunc(request.Requestor), ApproverNotes = request.ApproverNotes, EndTime = request.EndTime, Office = OfficeMetadataDTO.MapToDTOFunc(request.Office), OfficeUsedCapacity = capacity.OfficeUsedCapacity, RequestorNotes = request.RequestorNotes, SectionUsedCapacity = capacity.SectionUsedCapacity, StartTime = request.StartTime, WorkRequestId = request.WorkRequestId }); }
public SectionMetadataDTO UpdateOrCreateSection(SectionMetadataDTO SectionDTO) { Section newSection = null; if (SectionDTO.SectionId != Guid.Empty) { newSection = DbContext.Sections.Find(SectionDTO.SectionId); } if (newSection != null) // Edit existing { newSection.OfficeId = SectionDTO.OfficeId; newSection.SectionDescription = SectionDTO.SectionDescription; newSection.SectionName = SectionDTO.SectionName; newSection.SectionMaxCapacity = SectionDTO.SectionMaxCapacity; newSection.SectionSafeCapacity = SectionDTO.SectionSafeCapacity; } else // Create new Section { newSection = SectionMetadataDTO.MapToBaseFunc(SectionDTO); newSection.SectionId = Guid.NewGuid(); DbContext.Sections.Add(newSection); } DbContext.SaveChanges(); return(SectionMetadataDTO.MapToDTOFunc(newSection)); }
public SectionMetadataDTO UpdateOrCreateSection([FromBody] SectionMetadataDTO sectionDetailDTO) { return(Repository.UpdateOrCreateSection(sectionDetailDTO)); }