示例#1
0
        public void ClearAnimals()
        {
            UnitOfWork.CatRepository.Clear();
            UnitOfWork.FarmRepository.Clear();

            UnitOfWork.Commit();
        }
示例#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;
                }
            }
        }
示例#4
0
 public void Insert(Cat cat)
 {
     UnitOfWork.CatRepository.Insert(cat);
     UnitOfWork.Commit();
 }