コード例 #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
        public async Task <IActionResult> View(int id, bool returnPartial = false)
        {
            var requisition = await _dbContext.Requisitions.GetFullRequisitionById(id);

            if ((await _authorizationService.AuthorizeAsync(User, requisition, Policies.View)).Succeeded)
            {
                var model = RequisitionViewModel.GetViewModelFromRequisition(requisition);

                model.UserCanAccept = (await _authorizationService.AuthorizeAsync(User, requisition, Policies.Accept)).Succeeded;
                model.UserCanCreate = (await _authorizationService.AuthorizeAsync(User, requisition.Request, Policies.Edit)).Succeeded;
                model.RequestOrReplacingOrderPricesAreUsed = requisition.RequestOrReplacingOrderPeriodUsed;

                await _listToModelService.AddInformationFromListsToModel(model);

                model.EventLog = new EventLogModel
                {
                    Header          = "Rekvisitionshändelser",
                    Id              = "EventLog_Requisition",
                    DynamicLoadPath = $"Requisition/{nameof(GetEventLog)}/{id}",
                };
                if (returnPartial)
                {
                    return(PartialView(model));
                }
                return(View(model));
            }
            return(Forbid());
        }
コード例 #3
0
        public async Task <IActionResult> View(int id)
        {
            OrderGroup orderGroup = await _dbContext.OrderGroups.GetFullOrderGroupById(id);

            if ((await _authorizationService.AuthorizeAsync(User, orderGroup, Policies.View)).Succeeded)
            {
                var allowEdit = (await _authorizationService.AuthorizeAsync(User, orderGroup, Policies.Edit)).Succeeded;

                var activeRequestGroup = await _dbContext.RequestGroups.GetLastRequestGroupForOrderGroup(id);

                await _orderService.AddOrdersWithListsForGroup(orderGroup);

                await _requestService.AddListsForRequestGroup(activeRequestGroup);

                activeRequestGroup.Requests.ForEach(r => r.Order = orderGroup.Orders.Where(o => o.OrderId == r.OrderId).SingleOrDefault());

                var model = OrderGroupModel.GetModelFromOrderGroup(orderGroup, activeRequestGroup);
                await _listToModelService.AddInformationFromListsToModel(model);

                model.CustomerInformationModel = new CustomerInformationModel
                {
                    IsCustomer                  = true,
                    Name                        = model.CustomerName,
                    CreatedBy                   = model.CreatedBy,
                    OrganisationNumber          = model.CustomerOrganisationNumber,
                    PeppolId                    = model.CustomerPeppolId,
                    UnitName                    = model.CustomerUnitName,
                    DepartmentName              = model.UnitName,
                    ReferenceNumber             = model.CustomerReferenceNumber,
                    InvoiceReference            = model.InvoiceReference,
                    UseSelfInvoicingInterpreter = _cacheService.CustomerSettings.Any(c => c.CustomerOrganisationId == orderGroup.CustomerOrganisationId && c.UsedCustomerSettingTypes.Any(cs => cs == CustomerSettingType.UseSelfInvoicingInterpreter))
                };

                model.ActiveRequestGroup = RequestGroupViewModel.GetModelFromRequestGroup(activeRequestGroup, User.IsInRole(Roles.ApplicationAdministrator) || User.IsInRole(Roles.SystemAdministrator));

                await _listToModelService.AddInformationFromListsToModel(model.ActiveRequestGroup);

                model.AllowProcessing                      = activeRequestGroup.Status == RequestStatus.Accepted && (await _authorizationService.AuthorizeAsync(User, orderGroup, Policies.Accept)).Succeeded;
                model.AllowCancellation                    = orderGroup.AllowCancellation && (await _authorizationService.AuthorizeAsync(User, orderGroup, Policies.Cancel)).Succeeded;
                model.AllowNoAnswerConfirmation            = orderGroup.AllowNoAnswerConfirmation && allowEdit;
                model.AllowResponseNotAnsweredConfirmation = orderGroup.AllowResponseNotAnsweredConfirmation && allowEdit;
                model.AllowUpdateExpiry                    = orderGroup.AllowUpdateExpiry && allowEdit;
                model.UseAttachments = CachedUseAttachentSetting(orderGroup.CustomerOrganisationId);

                return(View(model));
            }
            return(Forbid());
        }
コード例 #4
0
        public async Task <IActionResult> View(int id)
        {
            var requestGroup = await _dbContext.RequestGroups.GetRequestGroupToView(id);

            OrderGroup orderGroup = await _dbContext.OrderGroups.GetFullOrderGroupById(requestGroup.OrderGroupId);

            if ((await _authorizationService.AuthorizeAsync(User, requestGroup, Policies.View)).Succeeded)
            {
                if (requestGroup.IsToBeProcessedByBroker)
                {
                    return(RedirectToAction(nameof(Process), new { id = requestGroup.RequestGroupId }));
                }

                await _orderService.AddOrdersWithListsForGroup(orderGroup);

                await _requestService.AddListsForRequestGroup(requestGroup);

                requestGroup.Requests.ForEach(r => r.Order = orderGroup.Orders.Where(o => o.OrderId == r.OrderId).SingleOrDefault());
                var model = RequestGroupViewModel.GetModelFromRequestGroup(requestGroup, true, false);
                await _listToModelService.AddInformationFromListsToModel(model);

                model.CustomerInformationModel.IsCustomer = false;
                model.CustomerInformationModel.UseSelfInvoicingInterpreter = _cacheService.CustomerSettings.Any(c => c.CustomerOrganisationId == requestGroup.OrderGroup.CustomerOrganisationId && c.UsedCustomerSettingTypes.Any(cs => cs == CustomerSettingType.UseSelfInvoicingInterpreter));
                model.OrderGroupModel = OrderGroupModel.GetModelFromOrderGroup(requestGroup.OrderGroup, requestGroup, true);
                await _listToModelService.AddInformationFromListsToModel(model.OrderGroupModel, requestGroup.OrderGroupId);

                if (requestGroup.QuarantineId.HasValue)
                {
                    List <OrderOccasionDisplayModel> tempOccasionList = new List <OrderOccasionDisplayModel>();
                    foreach (OrderOccasionDisplayModel occasion in model.OccasionList.Occasions)
                    {
                        var request = requestGroup.Requests.Single(r => r.RequestId == occasion.RouteId);
                        tempOccasionList.Add(OrderOccasionDisplayModel.GetModelFromOrder(request.Order, GetPriceinformationOrderToDisplay(request, model.OrderGroupModel.RequestedCompetenceLevels.ToList()), request));
                    }
                    model.OccasionList.Occasions = tempOccasionList;
                }
                model.OrderGroupModel.UseAttachments = true;
                return(View(model));
            }
            return(Forbid());
        }