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()); }
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()); }