Esempio n. 1
0
        public async Task <CassetteProperties> UpdateAsync(CassetteProperties request)
        {
            int id;

            if (int.TryParse(request.Num, out id))
            {
                int[] realContainersId = new int[] { id };
                var   statuses         = await _realContainerRepo.GetStatusesAsync();

                int?realContainerStatusId = statuses.ToList().Find(s => s.Name == request.Status)?.IdType;

                if (realContainerStatusId.HasValue)
                {
                    await _realContainerRepo.UpdateStatusAsync(realContainersId, realContainerStatusId.Value, false);
                }

                await _realContainerRepo.SetPropertiesAsync(realContainersId, request.AtRemove, request.AtCheck);

                var cas = await _realContainerRepo.GetAsync(realContainersId);

                return(_mapper.Map <RealContainer, CassetteProperties>(cas?.FirstOrDefault()));
            }

            return(null);
        }
Esempio n. 2
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 <List <RealContainer> > GetRealContainersByIdAsync(int[] realContainersId)
 {
     return(await _realcontainerRepository.GetAsync(realContainersId));
 }