Пример #1
0
        /// <summary>
        /// 物理删除库位信息
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        public async Task <OperationResult> DeleteMatWareHouseLocations(params Guid[] ids)
        {
            ids.CheckNotNull("ids");
            MatWareHouseLocationRepository.UnitOfWork.BeginTransaction();
            var result = await MatWareHouseLocationRepository.DeleteAsync(ids);

            MatWareHouseLocationRepository.UnitOfWork.Commit();
            return(result);
        }
        /// <summary>
        /// 物理删除库位信息
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        public async Task <OperationResult> DeleteMatWareHouseLocations(params Guid[] ids)
        {
            ids.CheckNotNull("ids");
            MatWareHouseLocationRepository.UnitOfWork.BeginTransaction();
            //
            OperationResult result = new OperationResult();
            //
            Guid matwarehouseareaInfoGuid = new Guid();

            foreach (Guid idsCurrent in ids)
            {
                matwarehouseareaInfoGuid = MatWareHouseLocationRepository.TrackEntities
                                           .Where(m => m.Id == idsCurrent)
                                           .Select(m => m.MatWareHouseArea.Id)
                                           .FirstOrDefault();
                //
                result = await MatWareHouseLocationRepository.DeleteAsync(ids);

                //
                int matwarehouseareaInfoNew2 = MatWareHouseLocationRepository.TrackEntities
                                               .Count(m => m.MatWareHouseArea.Id.Equals(matwarehouseareaInfoGuid));
                if (matwarehouseareaInfoNew2 == 0)
                {
                    MatWareHouseAreaInfo matwarehouseareaInfo = MatWareHouseAreaInfoRepository.TrackEntities
                                                                .Where(m => m.Id == matwarehouseareaInfoGuid)
                                                                .FirstOrDefault();
                    //matwarehouseareaInfo.Id = matwarehouseareaInfoGuid;
                    matwarehouseareaInfo.IsGenerageLocation = false;
                    matwarehouseareaInfo.LastUpdatedTime    = DateTime.Now;
                    //
                    await MatWareHouseAreaInfoRepository.UpdateAsync(matwarehouseareaInfo);
                }
            }
            //
            MatWareHouseLocationRepository.UnitOfWork.Commit();
            return(result);
        }