public async Task <StockItem> Create(string equipmentId, StockItemCreate create)
        {
            Equipment eq = await _equipment.Find <Equipment>(equipment => equipment.Id == equipmentId).FirstOrDefaultAsync();

            if (eq.Stock == null)
            {
                List <StockItem> stock   = new List <StockItem>();
                StockItem        created = StockItem.FromCreate(create);
                created.StockId = ObjectId.GenerateNewId().ToString();
                stock.Add(created);
                Equipment equipment = Equipment.FromUpdateStock(eq, stock);
                await _equipment.ReplaceOneAsync(equipment => equipment.Id == equipmentId, equipment);

                return(created);
            }
            else
            {
                List <StockItem> stock   = eq.Stock;
                StockItem        created = StockItem.FromCreate(create);
                created.StockId = ObjectId.GenerateNewId().ToString();
                stock.Add(created);
                Equipment equipment = Equipment.FromUpdateStock(eq, stock);
                await _equipment.ReplaceOneAsync(equipment => equipment.Id == equipmentId, equipment);

                return(created);
            }
        }
        public async Task <ActionResult <StockItem> > Create([FromHeader] string authToken, string equipmentId, StockItemCreate create)
        {
            if (!await _authenticationService.CheckAccess(authToken, "equipmentMgr"))
            {
                return(Unauthorized());
            }

            StockItem created = await _stockItemService.Create(equipmentId, create);

            Equipment eq = await _equipmentService.GetFromStockId(created.StockId);

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

            return(Ok(created));
        }