/// <summary>
        /// Adds the matter data.
        /// </summary>
        private void AddMatterData(ref Collection<SrvBookingMatter> bookingMatterTable, DsMattersForBooking dsBookingsMatters)
        {
            bookingMatterTable.Clear();
            for (int i = 0; i < dsBookingsMatters.MatterForBooking.Rows.Count; i++)
            {
                SrvBookingMatter bookingMatter = new SrvBookingMatter();
                bookingMatter.ProjectId = dsBookingsMatters.MatterForBooking[i].ProjectId;
                bookingMatter.Reference = dsBookingsMatters.MatterForBooking[i].matRef;
                bookingMatter.Description = dsBookingsMatters.MatterForBooking[i].matDescription;
                bookingMatter.KeyDescription = dsBookingsMatters.MatterForBooking[i].matKeyDescription;
                bookingMatter.OpenDate = dsBookingsMatters.MatterForBooking[i].matOpenDate;
                bookingMatter.feeReference = dsBookingsMatters.MatterForBooking[i].feeRef;
                bookingMatter.PartnerMemberId = dsBookingsMatters.MatterForBooking[i].matPartnerMemId;
                bookingMatter.Ufn = dsBookingsMatters.MatterForBooking[i].matUFN;
                bookingMatter.ClosedDate = dsBookingsMatters.MatterForBooking[i].matClosedDate;
                bookingMatter.BranchReference = dsBookingsMatters.MatterForBooking[i].matBranchRef;
                bookingMatter.WorkTypeCode = dsBookingsMatters.MatterForBooking[i].WorkTypeCode;
                bookingMatter.DepartmentReference = dsBookingsMatters.MatterForBooking[i].matDeptRef;

                bookingMatterTable.Add(bookingMatter);
            }
        }
        private void AddMatter(Guid projectId, ref SrvBookingEntry bookingEntryData)
        {
            try
            {
                var enquiryRepo = PmsInfrastructure.Container.Instance.Resolve<IEnquiryRepository>();
                var isActiveEnquiry = enquiryRepo.IsActiveEnquiry(projectId);

                DsMattersForBooking dsBookingMatter1 = SrvMatterLookup.GetMatterForBooking(projectId);
                DsMattersForBooking dsBookingsMatters = new DsMattersForBooking();

                if (dsBookingMatter1.MatterForBooking.Rows.Count == 0 && !isActiveEnquiry)
                    throw new ApplicationException("The matter could not be found");

                if (isActiveEnquiry)
                {
                    dsBookingsMatters.MatterForBooking.AddMatterForBookingRow(projectId.ToString(),
                    string.Empty,
                    string.Empty,
                    string.Empty,
                    DateTime.Now,
                    string.Empty,
                    enquiryRepo.GetPrimaryClientForEnquiry(projectId).ToString(),
                    string.Empty,
                    DataConstants.BlankDate,
                    string.Empty,
                    string.Empty,
                    string.Empty);
                }
                else
                {
                    dsBookingsMatters.MatterForBooking.AddMatterForBookingRow(dsBookingMatter1.MatterForBooking[0].ProjectId,
                    dsBookingMatter1.MatterForBooking[0].matRef,
                    dsBookingMatter1.MatterForBooking[0].matDescription,
                    dsBookingMatter1.MatterForBooking[0].matKeyDescription,
                    dsBookingMatter1.MatterForBooking[0].matOpenDate,
                    dsBookingMatter1.MatterForBooking[0].feeRef,
                    dsBookingMatter1.MatterForBooking[0].matPartnerMemId,
                    dsBookingMatter1.MatterForBooking[0].matUFN,
                    dsBookingMatter1.MatterForBooking[0].matClosedDate,
                    dsBookingMatter1.MatterForBooking[0].matBranchRef,
                    dsBookingMatter1.MatterForBooking[0].WorkTypeCode,
                    dsBookingMatter1.MatterForBooking[0].matDeptRef);
                }

                Collection<SrvBookingMatter> bookingMatterTableIndividual = new Collection<SrvBookingMatter>();
                AddMatterData(ref bookingMatterTableIndividual, dsBookingsMatters);
                bookingEntryData.BookingMatterTable = bookingMatterTableIndividual;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }