Exemple #1
0
        public async Task <int> UnbindRealContainersAsync(int[] realContainersId, int userId)
        {
            using (var sqlConnect = Connections.GetLM())
            {
                sqlConnect.Open();
                using (var tran = sqlConnect.BeginTransaction())
                {
                    var error = _storageTransferProxy.ContainerSet(realContainersId, userId, sqlConnect, tran);
                    if (!string.IsNullOrWhiteSpace(error))
                    {
                        throw new Exception(error);
                    }

                    // Если технологическая сумка, то при расформировании - удаляем ее
                    // TODO: вынести справочники в отдельный сервис
                    var sql = @"select top 1
                                  idCashContainerType
                                from dbo.vdrCashContainerType
                                where sCode = 'CashContainerType_TechBag'";
                    var idCashContainerTypeTechBag = await sqlConnect.ExecuteScalarAsync <int>(sql, null, tran);

                    var sets = (await _realRepo.GetAsync(realContainersId))
                               .Where(m => m.RealContainerTypeId == idCashContainerTypeTechBag)
                               .ToList();
                    foreach (var m in sets)
                    {
                        int[] containersId = new int[] { m.RealContainerId };
                        await _realRepo.DeleteAsync(containersId, true, sqlConnect, tran);
                    }

                    var result = await _realRepo.UpdateStatusAsync(
                        realContainersId,
                        (int)RealContainerStatusEnum.Free, false, tran);

                    tran.Commit();

                    return(result);
                }
            }
        }
 public async Task <int> DeleteRealContainersAsync(int[] realContainersId, bool force)
 {
     return(await _realcontainerRepository.DeleteAsync(realContainersId, force));
 }