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 OfficeMetadataDTO UpdateOrCreateOffice(OfficeMetadataDTO officeDTO)
        {
            Office newOffice = null;

            if (officeDTO.OfficeId != Guid.Empty)
            {
                newOffice = DbContext.Offices.Find(officeDTO.OfficeId);
            }
            if (newOffice != null) // Edit existing
            {
                newOffice.OfficeName         = officeDTO.OfficeName;
                newOffice.OfficeStreet       = officeDTO.OfficeStreet;
                newOffice.OfficeCity         = officeDTO.OfficeCity;
                newOffice.OfficeState        = officeDTO.OfficeState;
                newOffice.OfficeZip          = officeDTO.OfficeZip;
                newOffice.OfficeMaxCapacity  = officeDTO.OfficeMaxCapacity;
                newOffice.OfficeSafeCapacity = officeDTO.OfficeSafeCapacity;
            }
            else   // Create new office
            {
                newOffice          = OfficeMetadataDTO.MapToBaseFunc(officeDTO);
                newOffice.OfficeId = Guid.NewGuid();
                DbContext.Offices.Add(newOffice);
            }

            DbContext.SaveChanges();

            return(OfficeMetadataDTO.MapToDTOFunc(newOffice));
        }
Beispiel #3
0
 public OfficeMetadataDTO UpdateOrCreateOffice([FromBody] OfficeMetadataDTO officeDetailDTO)
 {
     return(Repository.UpdateOrCreateOffice(officeDetailDTO));
 }
        public async ValueTask <OfficeMetadataDTO> GetOfficeById(Guid officeId)
        {
            var office = await DbContext.Offices.FindAsync(officeId);

            return(OfficeMetadataDTO.MapToDTOFunc(office));
        }