public ActionResult <AuditTrailsDto> UpdateAudit(Guid auditId, Guid userId, AuditTrailsCreateDto auditTrails)
        {
            if (!_usersRepository.UserExists(userId).Result)
            {
                return(NotFound());
            }

            var result = _auditTrailsRepository.CreateAudit(userId, auditTrails).Result;

            return(CreatedAtRoute("GetUserAuditTrail",
                                  new { userId = userId, auditId = result.Id }, result));
        }
        public async Task <AuditTrailsDto> CreateAudit(Guid userId, AuditTrailsCreateDto auditTrail)
        {
            return(await Task.Run(async() =>
            {
                if (auditTrail == null)
                {
                    throw new ArgumentNullException(nameof(auditTrail));
                }
                var record = _mapper.Map <Entities.AuditTrail>(auditTrail);


                record.Id = Guid.NewGuid();
                record.UserId = userId;
                record.DateCreated = DateTime.Now;
                _context.AuditTrail.Add(record);

                //call the save method
                bool saveResult = await Save();

                //get the list of ids as string from the data
                return _mapper.Map <AuditTrailsDto>(record);
            }));
        }