Exemplo n.º 1
0
        public void ClearAnimals()
        {
            UnitOfWork.CatRepository.Clear();
            UnitOfWork.FarmRepository.Clear();

            UnitOfWork.Commit();
        }
Exemplo n.º 2
0
        /// <inheritdoc />
        public async Task CreateDeviceUsingDapperAsync(DeviceViewModel deviceViewModel)
        {
            // Validate input
            deviceValidationService
            .Validate(deviceViewModel);


            var device = mapper.Map <DeviceViewModel, Device>(deviceViewModel);

            dapperUnitOfWork.BeginTransaction();

            if (device.DeviceGroupId.Equals(Guid.Empty))
            {
                var deviceGroupRepository = dapperUnitOfWork.GetRepository <DeviceGroup>();
                device.DeviceGroupId = device.DeviceGroup.DeviceGroupId;
                await deviceGroupRepository.AddAsync(device.DeviceGroup);
            }

            var deviceRepository = dapperUnitOfWork.GetRepository <Device>();

            device.DeviceId = Guid.NewGuid();
            await deviceRepository.AddAsync(device);

            // Commit changes
            dapperUnitOfWork.Commit();
        }
        public IEnumerable <CustomerContract> Process(SearchTermRequest input)
        {
            using (_dapperUnitOfWork.Begin())
            {
                try
                {
                    _listQuery.BuildQuery(GetParameter(input));

                    var result = _runner.Run(_listQuery);

                    _dapperUnitOfWork.Commit();

                    return(result.Select(Map));
                }
                catch
                {
                    _dapperUnitOfWork.Rollback();

                    throw;
                }
            }
        }
Exemplo n.º 4
0
 public void Insert(Cat cat)
 {
     UnitOfWork.CatRepository.Insert(cat);
     UnitOfWork.Commit();
 }