コード例 #1
0
        private async Task <RequestModel> GetModel(Request request)
        {
            request.Order = await _dbContext.Orders.GetFullOrderByRequestId(request.RequestId);

            request.Order.Requirements = await _dbContext.OrderRequirements.GetRequirementsForOrder(request.OrderId).ToListAsync();

            var model = RequestModel.GetModelFromRequest(request);

            if (request.InterpreterLocation != null)
            {
                model.InterpreterLocationAnswer = model.OrderViewModel.InterpreterLocationAnswer = (InterpreterLocation)request.InterpreterLocation.Value;
            }
            if (request.Status == RequestStatus.CancelledByCreatorWhenApproved)
            {
                model.Info48HCancelledByCustomer = _dateCalculationService.GetNoOf24HsPeriodsWorkDaysBetween(request.CancelledAt.Value.DateTime, request.Order.StartAt.DateTime) < 2 ? "Detta är en avbokning som skett med mindre än 48 timmar till tolkuppdragets start. Därmed utgår full ersättning, inklusive bland annat spilltid och förmedlingsavgift, i de fall något ersättningsuppdrag inte kan ordnas av kund. Obs: Lördagar, söndagar och helgdagar räknas inte in i de 48 timmarna." : "Detta är en avbokning som skett med mer än 48 timmar till tolkuppdragets start. Därmed utgår förmedlingsavgift till leverantören. Obs: Lördagar, söndagar och helgdagar räknas inte in i de 48 timmarna.";
            }
            model.ViewedByUser = await _listToModelService.GetOtherViewer(request.RequestId, User.GetUserId());

            model.BrokerId = request.Ranking.BrokerId;
            model.OrderViewModel.ActiveRequest = new RequestViewModel
            {
                Status    = request.Status,
                CreatedAt = model.CreatedAt
            };
            model.OrderViewModel.UseAttachments = true;
            await _listToModelService.AddInformationFromListsToModel(model.OrderViewModel);

            model.OrderCalculatedPriceInformationModel = GetPriceinformationOrderToDisplay(request, model.OrderViewModel.RequestedCompetenceLevels);
            model.AttachmentListModel = model.OrderViewModel.RequestAttachmentListModel;
            model.OrderViewModel.CustomerUseSelfInvoicingInterpreter = _cacheService.CustomerSettings.Any(c => c.CustomerOrganisationId == request.Order.CustomerOrganisationId && c.UsedCustomerSettingTypes.Any(cs => cs == CustomerSettingType.UseSelfInvoicingInterpreter));
            model.BrokerReferenceNumber = request.BrokerReferenceNumber;
            return(model);
        }
コード例 #2
0
        [InlineData("2018-09-05 16:00:00", "2018-09-05 18:00:00", 0)]         // Part of day Wednesday (0 24h period)
        public void GetNoOf24HsPeriodsOfWorkDaysBetween(string firstDate, string secondDate, int actual)
        {
            using var tolkDbContext = CreateTolkDbContext(DbNameWithHolidays);
            var subject = new DateCalculationService(CreateCacheService(tolkDbContext));

            subject.GetNoOf24HsPeriodsWorkDaysBetween(DateTime.Parse(firstDate), DateTime.Parse(secondDate))
            .Should().Be(actual, "there are {0} full 24h periods of workday time between {1} and {2}", actual, firstDate, secondDate);
        }