public async Task <Guid> ExecuteAsync(CarePlanAssignmentDomain carePlanAssignment) { var serviceUser = await _getServiceUserUseCase.GetServiceUserInformation(carePlanAssignment.HackneyUserId); await _ensureSingleActivePackageTypePerUserUseCase.ExecuteAsync(serviceUser.Id, carePlanAssignment.PackageType); var documentResponse = new DocumentResponse(); if (carePlanAssignment.CarePlanFileId == Guid.Empty && carePlanAssignment.CarePlanFile != null) { documentResponse = await _fileStorage.SaveFileAsync(ConvertCarePlan(carePlanAssignment.CarePlanFile), carePlanAssignment.CarePlanFile?.FileName); } var package = new CarePackage { ServiceUserId = serviceUser.Id, BrokerId = carePlanAssignment.BrokerId, PackageType = carePlanAssignment.PackageType, Status = PackageStatus.New, DateAssigned = DateTimeOffset.UtcNow, PackageScheduling = PackageScheduling.Temporary, // TODO: Review if package scheduling can be made nullable }; if (documentResponse.FileId != Guid.Empty) { package.Resources.Add(new CarePackageResource() { FileId = documentResponse.FileId, FileExtension = Path.GetExtension(documentResponse.FileName), Name = documentResponse.FileName, Type = PackageResourceType.CarePlanFile, }); } package.Histories.Add(new CarePackageHistory { Status = HistoryStatus.NewPackage, Description = HistoryStatus.NewPackage.GetDisplayName(), RequestMoreInformation = carePlanAssignment.Notes }); _carePackageGateway.Create(package); await _dbManager.SaveAsync(); return(package.Id); }
public async Task <ActionResult <ServiceUserResponse> > GetServiceUserInformation(int hackneyId) { var result = await _getServiceUserUseCase.GetServiceUserInformation(hackneyId); return(Ok(result)); }