Example #1
0
        public async Task <BudgetRequest> Create(BudgetRequestCreate budgetRequestIn, string labGroupId)
        {
            var budgetRequest = BudgetRequest.FromCreate(budgetRequestIn, labGroupId);
            await _budgetRequests.InsertOneAsync(budgetRequest);

            return(budgetRequest);
        }
Example #2
0
        public async Task <ActionResult <BudgetRequest> > Create([FromHeader] string authToken, BudgetRequestCreate budgetRequest)
        {
            if (!await _authenticationService.CheckAccess(authToken, "announceView"))
            {
                return(Unauthorized());
            }

            LabGroup group = await _labGroupService.GetByMemberId(AuthenticationHelpers.GetUserIdFromToken(authToken));

            BudgetRequest created = await _budgetRequestService.Create(budgetRequest, group.Id);

            await _logService.Create(new Log(
                                         null,
                                         AuthenticationHelpers.GetUserIdFromToken(authToken),
                                         DateTime.UtcNow,
                                         "Document created.",
                                         "budgetRequests",
                                         created.Id,
                                         JsonSerializer.Serialize(created)
                                         ));

            return(Ok(budgetRequest));
        }