コード例 #1
0
        internal static RequestGroupProcessModel GetModelFromRequestGroup(RequestGroup requestGroup, Guid fileGroupKey, long combinedMaxSizeAttachments, bool allowDeclineExtraInterpreter)
        {
            OrderGroup orderGroup = requestGroup.OrderGroup;
            Order      order      = requestGroup.Requests.First().Order;

            return(new RequestGroupProcessModel
            {
                AllowDeclineExtraInterpreter = allowDeclineExtraInterpreter,
                OrderGroupId = requestGroup.OrderGroupId,
                RequestGroupId = requestGroup.RequestGroupId,
                BrokerId = requestGroup.Ranking.BrokerId,
                OrderGroupNumber = orderGroup.OrderGroupNumber,
                FileGroupKey = fileGroupKey,
                CombinedMaxSizeAttachments = combinedMaxSizeAttachments,
                CreatedAt = requestGroup.CreatedAt,
                ExpiresAt = requestGroup.ExpiresAt.Value,
                OccasionList = new OccasionListModel
                {
                    Occasions = requestGroup.Requests.Where(r => r.Status != RequestStatus.InterpreterReplaced)
                                .Select(r => OrderOccasionDisplayModel.GetModelFromOrder(r.Order, PriceInformationModel.GetPriceinformationToDisplay(r.Order, alwaysUseOrderPriceRows: false), r)),
                    AllOccasions = orderGroup.Orders.Select(o => OrderOccasionDisplayModel.GetModelFromOrder(o, request: o.Requests.OrderBy(re => re.RequestId).Last()))
                },
                HasExtraInterpreter = requestGroup.HasExtraInterpreter,
                OrderHasAllowExceedingTravelCost = orderGroup.AllowExceedingTravelCost == BusinessLogic.Enums.AllowExceedingTravelCost.YesShouldBeApproved || orderGroup.AllowExceedingTravelCost == BusinessLogic.Enums.AllowExceedingTravelCost.YesShouldNotBeApproved,
                AllowExceedingTravelCost = new RadioButtonGroup {
                    SelectedItem = orderGroup.FirstOrder.AllowExceedingTravelCost == null ? null : SelectListService.BoolList.Single(e => e.Value == EnumHelper.Parent <AllowExceedingTravelCost, TrueFalse>(orderGroup.FirstOrder.AllowExceedingTravelCost.Value).ToString())
                },
                CreatorIsInterpreterUser = orderGroup.CreatorIsInterpreterUser.HasValue ? new RadioButtonGroup {
                    SelectedItem = SelectListService.BoolList.Single(e => e.Value == (orderGroup.CreatorIsInterpreterUser.Value ? TrueFalse.Yes.ToString() : TrueFalse.No.ToString()))
                } : null,
                AssignmentType = orderGroup.AssignmentType,
                CustomerInformationModel = new CustomerInformationModel
                {
                    CreatedBy = orderGroup.CreatedByUser.CompleteContactInformation,
                    Name = orderGroup.CustomerOrganisation.Name,
                    UnitName = orderGroup.CustomerUnit?.Name,
                    DepartmentName = order.UnitName,
                    InvoiceReference = order.InvoiceReference,
                    OrganisationNumber = orderGroup.CustomerOrganisation.OrganisationNumber,
                    PeppolId = orderGroup.CustomerOrganisation.PeppolId,
                    ReferenceNumber = order.CustomerReferenceNumber
                },
                Description = order.Description,
                LanguageName = orderGroup.LanguageName,
                LanguageHasAuthorizedInterpreter = orderGroup.LanguageHasAuthorizedInterpreter,
                RankedInterpreterLocationFirstAddressModel = OrderModel.GetInterpreterLocation(order.InterpreterLocations.Single(l => l.Rank == 1)),
                RankedInterpreterLocationSecondAddressModel = OrderModel.GetInterpreterLocation(order.InterpreterLocations.SingleOrDefault(l => l.Rank == 2)),
                RankedInterpreterLocationThirdAddressModel = OrderModel.GetInterpreterLocation(order.InterpreterLocations.SingleOrDefault(l => l.Rank == 3)),
                RegionName = orderGroup.Region.Name,
                SpecificCompetenceLevelRequired = orderGroup.SpecificCompetenceLevelRequired,
                Status = requestGroup.Status,
            });
        }
コード例 #2
0
        internal static OrderGroupModel GetModelFromOrderGroup(OrderGroup orderGroup, RequestGroup activeRequestGroup, bool displayForBroker = false)
        {
            bool useRankedInterpreterLocation = orderGroup.FirstOrder.InterpreterLocations.Count > 1;
            var  model = new OrderGroupModel
            {
                AllowExceedingTravelCost = displayForBroker ? new RadioButtonGroup
                {
                    SelectedItem = orderGroup.FirstOrder.AllowExceedingTravelCost == null ? null :
                                   SelectListService.BoolList.Single(e => e.Value == EnumHelper.Parent <AllowExceedingTravelCost, TrueFalse>(orderGroup.FirstOrder.AllowExceedingTravelCost.Value).ToString())
                } :
                new RadioButtonGroup
                {
                    SelectedItem = orderGroup.FirstOrder.AllowExceedingTravelCost == null ? null :
                                   SelectListService.AllowExceedingTravelCost.Single(e => e.Value == orderGroup.FirstOrder.AllowExceedingTravelCost.ToString())
                },
                IsCreatorInterpreterUser = orderGroup.CreatorIsInterpreterUser,
                Description = orderGroup.FirstOrder.Description,
                CompetenceLevelDesireType = new RadioButtonGroup
                {
                    SelectedItem = orderGroup.SpecificCompetenceLevelRequired
                    ? SelectListService.DesireTypes.Single(item => EnumHelper.Parse <DesireType>(item.Value) == DesireType.Requirement)
                    : SelectListService.DesireTypes.Single(item => EnumHelper.Parse <DesireType>(item.Value) == DesireType.Request)
                },
                Status = orderGroup.Status,

                RankedInterpreterLocationFirst              = orderGroup.FirstOrder.InterpreterLocations.Single(l => l.Rank == 1)?.InterpreterLocation,
                RankedInterpreterLocationSecond             = orderGroup.FirstOrder.InterpreterLocations.SingleOrDefault(l => l.Rank == 2)?.InterpreterLocation,
                RankedInterpreterLocationThird              = orderGroup.FirstOrder.InterpreterLocations.SingleOrDefault(l => l.Rank == 3)?.InterpreterLocation,
                RankedInterpreterLocationFirstAddressModel  = GetInterpreterLocation(orderGroup.FirstOrder.InterpreterLocations.Single(l => l.Rank == 1)),
                RankedInterpreterLocationSecondAddressModel = GetInterpreterLocation(orderGroup.FirstOrder.InterpreterLocations.SingleOrDefault(l => l.Rank == 2)),
                RankedInterpreterLocationThirdAddressModel  = GetInterpreterLocation(orderGroup.FirstOrder.InterpreterLocations.SingleOrDefault(l => l.Rank == 3)),
                OrderGroupId     = orderGroup.OrderGroupId,
                OrderGroupNumber = orderGroup.OrderGroupNumber,

                CreatedBy                  = orderGroup.ContactInformation,
                CreatedAt                  = orderGroup.CreatedAt,
                InvoiceReference           = orderGroup.FirstOrder.InvoiceReference,
                CustomerName               = orderGroup.CustomerOrganisation.Name,
                CustomerOrganisationNumber = orderGroup.CustomerOrganisation.OrganisationNumber,
                CustomerPeppolId           = orderGroup.CustomerOrganisation.PeppolId,
                CustomerReferenceNumber    = orderGroup.FirstOrder.CustomerReferenceNumber,
                LanguageName               = orderGroup.OtherLanguage ?? orderGroup.Language?.Name ?? "-",
                CustomerUnitName           = orderGroup.CustomerUnit?.Name ?? string.Empty,
                UnitName   = orderGroup.FirstOrder.UnitName,
                RegionName = orderGroup.Region.Name,
                LanguageHasAuthorizedInterpreter = orderGroup.LanguageHasAuthorizedInterpreter,

                RequestGroupId = activeRequestGroup?.RequestGroupId,
                AssignmentType = orderGroup.AssignmentType,
                OccasionList   = new OccasionListModel
                {
                    Occasions = orderGroup.Orders
                                .Select(o => OrderOccasionDisplayModel.GetModelFromOrder(o, PriceInformationModel.GetPriceinformationToDisplay(o, alwaysUseOrderPriceRows: false))),
                    AllOccasions        = orderGroup.Orders.Select(o => OrderOccasionDisplayModel.GetModelFromOrder(o)),
                    DisplayDetailedList = true
                },

                //those values should only be presented if ordergroup should be approved/denied since they could be changed (or display that this is the first occasions cost)?
                ExpectedTravelCostInfo = activeRequestGroup?.FirstRequestForFirstInterpreter.ExpectedTravelCostInfo,
                ExpectedTravelCosts    = activeRequestGroup?.FirstRequestForFirstInterpreter.PriceRows.FirstOrDefault(pr => pr.PriceRowType == PriceRowType.TravelCost)?.Price ?? 0,
                ExtraInterpreterExpectedTravelCostInfo = activeRequestGroup.HasExtraInterpreter ? activeRequestGroup?.FirstRequestForExtraInterpreter.ExpectedTravelCostInfo : null,
                ExtraInterpreterExpectedTravelCosts    = activeRequestGroup.HasExtraInterpreter ? activeRequestGroup?.FirstRequestForExtraInterpreter.PriceRows.FirstOrDefault(pr => pr.PriceRowType == PriceRowType.TravelCost)?.Price ?? 0 : 0,
            };

            return(model);
        }
コード例 #3
0
        internal static RequestGroupViewModel GetModelFromRequestGroup(RequestGroup requestGroup, bool displayBrokerReferenceNumber, bool isCustomer = true)
        {
            OrderGroup orderGroup = requestGroup.OrderGroup;
            Order      order      = requestGroup.FirstRequestForFirstInterpreter.Order;
            Request    request    = requestGroup.FirstRequestForFirstInterpreter;
            Request    requestExtraInterpreter = requestGroup.HasExtraInterpreter ? requestGroup.FirstRequestForExtraInterpreter : null;
            Order      orderExtraInterpreter   = requestExtraInterpreter?.Order;

            var  verificationResult    = request.InterpreterCompetenceVerificationResultOnStart ?? request.InterpreterCompetenceVerificationResultOnAssign;
            bool?isInterpreterVerified = verificationResult.HasValue ? (bool?)(verificationResult == VerificationResult.Validated) : null;
            var  extraInterpreterVerificationResult = requestExtraInterpreter != null ? (requestExtraInterpreter.InterpreterCompetenceVerificationResultOnStart ?? requestExtraInterpreter.InterpreterCompetenceVerificationResultOnAssign) : null;
            bool?isExtraInterpreterVerified         = extraInterpreterVerificationResult.HasValue ? (bool?)(extraInterpreterVerificationResult == VerificationResult.Validated) : null;

            return(new RequestGroupViewModel
            {
                AllowConfirmationDenial = requestGroup.Status == RequestStatus.DeniedByCreator && !requestGroup.StatusConfirmations.Any(rs => rs.RequestStatus == RequestStatus.DeniedByCreator),
                AllowConfirmNoAnswer = requestGroup.Status == RequestStatus.ResponseNotAnsweredByCreator && !requestGroup.StatusConfirmations.Any(rs => rs.RequestStatus == RequestStatus.ResponseNotAnsweredByCreator),
                AssignmentType = order.AssignmentType,
                CreatedAt = orderGroup.CreatedAt,
                OrderGroupId = requestGroup.OrderGroupId,
                RequestGroupId = requestGroup.RequestGroupId,
                OrderGroupNumber = orderGroup.OrderGroupNumber,
                AnsweredBy = requestGroup.AnsweringUser?.CompleteContactInformation,
                Broker = requestGroup.Ranking.Broker.BrokerContactInformation,
                BrokerOrganizationNumber = requestGroup.Ranking?.Broker.OrganizationNumber,
                DenyMessage = requestGroup.DenyMessage,
                CancelMessage = requestGroup.CancelMessage,
                ExpiresAt = requestGroup.ExpiresAt,
                LatestAnswerTimeForCustomer = requestGroup.LatestAnswerTimeForCustomer,
                CustomerInformationModel = new CustomerInformationModel
                {
                    CreatedBy = orderGroup.CreatedByUser.CompleteContactInformation,
                    Name = orderGroup.CustomerOrganisation.Name,
                    UnitName = orderGroup.CustomerUnit?.Name,
                    DepartmentName = order.UnitName,
                    InvoiceReference = order.InvoiceReference,
                    OrganisationNumber = orderGroup.CustomerOrganisation.OrganisationNumber,
                    PeppolId = orderGroup.CustomerOrganisation.PeppolId,
                    ReferenceNumber = order.CustomerReferenceNumber
                },
                OccasionList = new OccasionListModel
                {
                    Occasions = requestGroup.Requests.Where(r => r.Status != RequestStatus.InterpreterReplaced)
                                .Select(r => OrderOccasionDisplayModel.GetModelFromOrder(r.Order, PriceInformationModel.GetPriceinformationToDisplay(r.Order, alwaysUseOrderPriceRows: false), request: isCustomer ? null : r)),
                    AllOccasions = orderGroup.Orders.Select(o => OrderOccasionDisplayModel.GetModelFromOrder(o, request: isCustomer ? null : o.Requests.OrderBy(re => re.RequestId).Last())),
                    DisplayDetailedList = true
                },
                InterpreterAnswerModel = new InterpreterAnswerModel
                {
                    RequiredRequirementAnswers = order.Requirements.Where(r => r.IsRequired).Select(r => new RequestRequirementAnswerModel
                    {
                        OrderRequirementId = r.OrderRequirementId,
                        IsRequired = true,
                        Description = r.Description,
                        RequirementType = r.RequirementType,
                        Answer = request.RequirementAnswers != null ? request.RequirementAnswers.FirstOrDefault(ra => ra.OrderRequirementId == r.OrderRequirementId)?.Answer : string.Empty,
                        CanMeetRequirement = request.RequirementAnswers != null && (request.RequirementAnswers.Any() && request.RequirementAnswers.FirstOrDefault(ra => ra.OrderRequirementId == r.OrderRequirementId).CanSatisfyRequirement),
                    }).ToList(),
                    DesiredRequirementAnswers = order.Requirements.Where(r => !r.IsRequired).Select(r => new RequestRequirementAnswerModel
                    {
                        OrderRequirementId = r.OrderRequirementId,
                        IsRequired = false,
                        Description = r.Description,
                        RequirementType = r.RequirementType,
                        Answer = request.RequirementAnswers != null ? request.RequirementAnswers.FirstOrDefault(ra => ra.OrderRequirementId == r.OrderRequirementId)?.Answer : string.Empty,
                        CanMeetRequirement = request.RequirementAnswers != null && (request.RequirementAnswers.Any() && request.RequirementAnswers.FirstOrDefault(ra => ra.OrderRequirementId == r.OrderRequirementId).CanSatisfyRequirement),
                    }).ToList(),
                },
                ExtraInterpreterAnswerModel = requestGroup.HasExtraInterpreter ? new InterpreterAnswerModel
                {
                    RequiredRequirementAnswers = orderExtraInterpreter.Requirements.Where(r => r.IsRequired).Select(r => new RequestRequirementAnswerModel
                    {
                        OrderRequirementId = r.OrderRequirementId,
                        IsRequired = true,
                        Description = r.Description,
                        RequirementType = r.RequirementType,
                        Answer = requestExtraInterpreter.RequirementAnswers != null ? requestExtraInterpreter.RequirementAnswers.FirstOrDefault(ra => ra.OrderRequirementId == r.OrderRequirementId)?.Answer : string.Empty,
                        CanMeetRequirement = requestExtraInterpreter.RequirementAnswers != null && (requestExtraInterpreter.RequirementAnswers.Any() && requestExtraInterpreter.RequirementAnswers.FirstOrDefault(ra => ra.OrderRequirementId == r.OrderRequirementId).CanSatisfyRequirement),
                    }).ToList(),
                    DesiredRequirementAnswers = orderExtraInterpreter.Requirements.Where(r => !r.IsRequired).Select(r => new RequestRequirementAnswerModel
                    {
                        OrderRequirementId = r.OrderRequirementId,
                        IsRequired = false,
                        Description = r.Description,
                        RequirementType = r.RequirementType,
                        Answer = requestExtraInterpreter.RequirementAnswers != null ? requestExtraInterpreter.RequirementAnswers.FirstOrDefault(ra => ra.OrderRequirementId == r.OrderRequirementId)?.Answer : string.Empty,
                        CanMeetRequirement = requestExtraInterpreter.RequirementAnswers != null && (requestExtraInterpreter.RequirementAnswers.Any() && requestExtraInterpreter.RequirementAnswers.FirstOrDefault(ra => ra.OrderRequirementId == r.OrderRequirementId).CanSatisfyRequirement),
                    }).ToList(),
                } : null,
                HasExtraInterpreter = requestGroup.HasExtraInterpreter,
                Description = order.Description,
                LanguageName = orderGroup.LanguageName,
                Dialect = order.Requirements.Any(r => r.RequirementType == RequirementType.Dialect) ? order.Requirements.Single(r => r.RequirementType == RequirementType.Dialect)?.Description : string.Empty,
                LanguageHasAuthorizedInterpreter = orderGroup.LanguageHasAuthorizedInterpreter,
                InterpreterLocation = request.InterpreterLocation.HasValue ? (InterpreterLocation?)request.InterpreterLocation.Value : null,
                DisplayExpectedTravelCostInfo = GetDisplayExpectedTravelCostInfo(request.Order, request.InterpreterLocation ?? 0),
                Interpreter = request.Interpreter?.CompleteContactInformation,
                ExtraInterpreter = requestGroup.HasExtraInterpreter ? requestExtraInterpreter.Interpreter?.CompleteContactInformation : null,

                IsInterpreterVerified = verificationResult.HasValue ? (bool?)(verificationResult == VerificationResult.Validated) : null,
                IsExtraInterpreterVerified = extraInterpreterVerificationResult.HasValue ? (bool?)(extraInterpreterVerificationResult == VerificationResult.Validated) : null,
                InterpreterVerificationMessage = verificationResult.HasValue ? verificationResult.Value.GetDescription() : null,
                ExtraInterpreterVerificationMessage = extraInterpreterVerificationResult.HasValue ? extraInterpreterVerificationResult.Value.GetDescription() : null,
                InterpreterCompetenceLevel = (CompetenceAndSpecialistLevel?)request.CompetenceLevel,
                ExtraInterpreterCompetenceLevel = requestGroup.HasExtraInterpreter ? (CompetenceAndSpecialistLevel?)requestExtraInterpreter.CompetenceLevel : null,
                ExpectedTravelCosts = request.PriceRows.FirstOrDefault(pr => pr.PriceRowType == PriceRowType.TravelCost)?.Price ?? 0,
                ExpectedTravelCostInfo = request.ExpectedTravelCostInfo,
                ExtraInterpreterExpectedTravelCosts = requestGroup.HasExtraInterpreter ? requestExtraInterpreter.PriceRows.FirstOrDefault(pr => pr.PriceRowType == PriceRowType.TravelCost)?.Price ?? 0 : 0,
                ExtraInterpreterExpectedTravelCostInfo = requestGroup.HasExtraInterpreter ? requestExtraInterpreter.ExpectedTravelCostInfo : null,
                RegionName = orderGroup.Region.Name,
                SpecificCompetenceLevelRequired = orderGroup.SpecificCompetenceLevelRequired,
                Status = requestGroup.Status,
                ExtraInterpreterStatus = requestExtraInterpreter?.Status,
                OrderStatus = orderGroup.Status,
                BrokerReferenceNumber = displayBrokerReferenceNumber ? requestGroup.BrokerReferenceNumber : null
            });
        }