Пример #1
0
        //Move it out to a repository
        public BookingProvisionDTO GetDkbsBookingProvisionSummary(int bookingId)
        {
            BookingProvisionDTO bookingProvisionDTO = new BookingProvisionDTO();
            var booking = GetById <Booking>(x => x.BookingId == bookingId);

            //Adding PartnerCoursePackages
            var bookingArrangementTypes = GetAll <BookingArrangementType>(x => x.BookingId == booking.BookingId);

            foreach (var bookingArrangementType in bookingArrangementTypes)
            {
                BookingArrangementTypeProvisionDTO bookingArrangementTypeProvisionDTO = new BookingArrangementTypeProvisionDTO();
                var coursePackage = GetById <CoursePackage>(x => x.CoursePackageId == bookingArrangementType.CoursePackageId);
                bookingArrangementTypeProvisionDTO.CoursePackageName    = coursePackage.CoursePackageName;
                bookingArrangementTypeProvisionDTO.NumberOfParticipants = bookingArrangementType.NumberOfParticipants;
                bookingArrangementTypeProvisionDTO.CommissionRateDkbs   = booking.CommissionRateDkbs;

                var partnerCoursePackage = GetById <PartnerCoursePackage>(x => x.CRMPartnerId == booking.CRMPartnerId);
                bookingArrangementTypeProvisionDTO.PartnerCoursePackagePrice = partnerCoursePackage?.Price;


                bookingProvisionDTO.BookingArrangementTypeProvisionDTOs.Add(bookingArrangementTypeProvisionDTO);
            }

            // Adding Booking Rooms
            var bookingRooms = GetAll <BookingRoom>(x => x.BookingId == booking.BookingId);

            foreach (var bookingRoom in bookingRooms)
            {
                BookingRoomProvisionDTO bookingRoomProvisionDTO = new BookingRoomProvisionDTO();
                bookingRoomProvisionDTO.RoomType      = bookingRoom.RoomType;
                bookingRoomProvisionDTO.NumberOfRooms = bookingRoom.NumberOfRooms;
                bookingRoomProvisionDTO.Persons       = bookingRoom.Persons;
                bookingProvisionDTO.BookingRoomProvisionDTOs.Add(bookingRoomProvisionDTO);
            }

            // Adding Booking AlternativeServices
            var bookingAlternativeServices = GetAll <BookingAlternativeService>(x => x.BookingId == booking.BookingId);

            foreach (var bookingAlternativeService in bookingAlternativeServices)
            {
                BookingAlternativeServiceProvisionDTO bookingAlternativeServiceProvisionDTO = new BookingAlternativeServiceProvisionDTO();
                bookingAlternativeServiceProvisionDTO.Description    = bookingAlternativeService.Description;
                bookingAlternativeServiceProvisionDTO.NumberOfPieces = bookingAlternativeService.NumberOfPieces;
                bookingProvisionDTO.BookingAlternativeServiceProvisionDTOs.Add(bookingAlternativeServiceProvisionDTO);
            }

            bookingProvisionDTO.ArrivalDate             = booking.Arrival;
            bookingProvisionDTO.BookKeepersCommentsDkbs = booking.BookkeepersCommentsDkbs;
            bookingProvisionDTO.CentersCommentsDkbs     = booking.CentersCommentsDkbs;
            bookingProvisionDTO.CommissionRateDkbs      = booking.CommissionRateDkbs;
            bookingProvisionDTO.DifferenceInDaysDkbs    = booking.DifferenceInDaysDkbs;
            bookingProvisionDTO.EstimatedByCenter       = booking.EstimatedByCenter;
            bookingProvisionDTO.EstimatedByDkbs         = booking.EstimatedByDkbs;
            bookingProvisionDTO.EvaluationDate          = booking.EvaluationDate;
            bookingProvisionDTO.ReferralRate            = booking.ReferralRate;
            bookingProvisionDTO.WinnerSelectedDate      = booking.WinnerSelectedDate;

            return(bookingProvisionDTO);
        }
Пример #2
0
        public ActionResult <PartnerBookingProvisionDTO> GetWinnerPartnerAndBookingProvisionDetails(int bookingId)
        {
            PartnerBookingProvisionDTO partnerBookingProvisionDTO = new PartnerBookingProvisionDTO();

            #region GetBookingData
            BookingProvisionDTO bookingProvisionDTO = new BookingProvisionDTO();
            var dbContext        = _unitOfWork.BookingRepository.DkbsContext;
            var booking          = _unitOfWork.BookingRepository.GetById(x => x.BookingId == bookingId);
            var Procedures       = dbContext.Procedure.Where(x => x.BookingId == bookingId);//.FirstOrDefault();
            var WinningProcedure = Procedures.Where(x => x.ProcedureStatusId == 2).FirstOrDefault();

            if (WinningProcedure == null)
            {
                ModelState.AddModelError("GetWinnerPartnerAndBookingProvisionDetails",
                                         $"There is no entry found for booking id : {bookingId}.");
                return(BadRequest(ModelState));
            }


            //Adding  Booking commisionrate dkbs, bookingArrangementType and PartnerCoursePackages details
            var bookingArrangementTypes = dbContext.BookingArrangementType.Where(x => x.BookingId == booking.BookingId).ToList();

            foreach (var bookingArrangementType in bookingArrangementTypes)
            {
                var ProcedureArrangementType = dbContext.ProcedureArrangementType.Where(x => x.BookingArrangementTypeId == bookingArrangementType.BookingArrangementTypeId && x.ProcedureId == WinningProcedure.ProcedureId).FirstOrDefault();
                BookingArrangementTypeProvisionDTO bookingArrangementTypeProvisionDTO = new BookingArrangementTypeProvisionDTO();

                //Gets the partner course package to get the corrosponding course package price
                var partnerCoursePackageInDb = dbContext.PartnerCoursePackage
                                               .Where(x => x.CRMPartnerId == WinningProcedure.CRMPartnerId &&
                                                      x.CoursePackageId == bookingArrangementType.CoursePackageId)
                                               .FirstOrDefault();


                //Get course package to get the name of the course package
                var coursePackageInDb = dbContext.CoursePackage
                                        .Where(x => x.CoursePackageId == bookingArrangementType.CoursePackageId).FirstOrDefault();

                bookingArrangementTypeProvisionDTO.CoursePackageName         = coursePackageInDb?.CoursePackageName;
                bookingArrangementTypeProvisionDTO.NumberOfParticipants      = bookingArrangementType.NumberOfParticipants;
                bookingArrangementTypeProvisionDTO.CommissionRateDkbs        = booking.CommissionRateDkbs;
                bookingArrangementTypeProvisionDTO.PartnerCoursePackagePrice = partnerCoursePackageInDb?.Price;
                bookingArrangementTypeProvisionDTO.TotalPrice = ProcedureArrangementType?.TotalPrice;
                bookingProvisionDTO.BookingArrangementTypeProvisionDTOs.Add(bookingArrangementTypeProvisionDTO);
            }

            // Adding Booking Rooms
            var bookingRooms = dbContext.BookingRoom.Where(x => x.BookingId == booking.BookingId).ToList();
            foreach (var bookingRoom in bookingRooms)
            {
                var ProcedureRoom = dbContext.ProcedureRoom.Where(x => x.BookingRoomId == bookingRoom.BookingRoomId && x.ProcedureId == WinningProcedure.ProcedureId).FirstOrDefault();
                BookingRoomProvisionDTO bookingRoomProvisionDTO = new BookingRoomProvisionDTO();
                bookingRoomProvisionDTO.RoomType      = bookingRoom.RoomType;
                bookingRoomProvisionDTO.NumberOfRooms = bookingRoom.NumberOfRooms;
                bookingRoomProvisionDTO.Persons       = bookingRoom.Persons;
                bookingRoomProvisionDTO.PricePerRoom  = ProcedureRoom?.PricePerRoom;
                bookingRoomProvisionDTO.TotalPrice    = ProcedureRoom?.TotalPrice;
                bookingProvisionDTO.BookingRoomProvisionDTOs.Add(bookingRoomProvisionDTO);
            }

            // Adding Booking AlternativeServices
            var bookingAlternativeServices = dbContext.BookingAlternativeService.Where(x => x.BookingId == booking.BookingId).ToList();
            foreach (var bookingAlternativeService in bookingAlternativeServices)
            {
                var ProcedureAlternativeService = dbContext.ProcedureAlternativeService.Where(x => x.BookingAlternativeServiceId == bookingAlternativeService.BookingAlternativeServiceId && x.ProcedureId == WinningProcedure.ProcedureId).FirstOrDefault();
                BookingAlternativeServiceProvisionDTO bookingOtherDetailsProvisionDTO = new BookingAlternativeServiceProvisionDTO();
                bookingOtherDetailsProvisionDTO.Description    = bookingAlternativeService.Description;
                bookingOtherDetailsProvisionDTO.NumberOfPieces = bookingAlternativeService.NumberOfPieces;
                bookingOtherDetailsProvisionDTO.PricePerPiece  = ProcedureAlternativeService?.PricePerPiece;
                bookingOtherDetailsProvisionDTO.TotaPrice      = ProcedureAlternativeService?.TotalPrice;
                bookingProvisionDTO.BookingAlternativeServiceProvisionDTOs.Add(bookingOtherDetailsProvisionDTO);
            }

            bookingProvisionDTO.ArrivalDate                = booking.Arrival;
            bookingProvisionDTO.BookKeepersCommentsDkbs    = booking.BookkeepersCommentsDkbs;
            bookingProvisionDTO.CentersCommentsDkbs        = booking.CentersCommentsDkbs;
            bookingProvisionDTO.CommissionRateDkbs         = booking.CommissionRateDkbs;
            bookingProvisionDTO.DifferenceInDaysDkbs       = booking.DifferenceInDaysDkbs;
            bookingProvisionDTO.EstimatedByCenter          = booking.EstimatedByCenter;
            bookingProvisionDTO.EstimatedByDkbs            = booking.EstimatedByDkbs;
            bookingProvisionDTO.EvaluationDate             = booking.EvaluationDate;
            bookingProvisionDTO.ReferralRate               = booking.ReferralRate;
            bookingProvisionDTO.WinnerSelectedDate         = booking.WinnerSelectedDate;
            bookingProvisionDTO.BookingStatusId            = booking.BookingAndStatusId;
            partnerBookingProvisionDTO.BookingProvisionDTO = bookingProvisionDTO;

            #endregion

            #region GetPartnerProvision Data

            var winnerPartnerProvision = GetSingleWinnerPartnerProvisionResult(WinningProcedure.CRMPartnerId);

            partnerBookingProvisionDTO.WPartnerDTO = winnerPartnerProvision;

            #endregion

            return(Ok(partnerBookingProvisionDTO));
        }