コード例 #1
0
        public SoftwareAssetModel UpdateSoftwareAsset(SoftwareAssetModel softwareAssetModel)
        {
            using (var scope = new TransactionScope(TransactionScopeOption.Required))
            {
                try
                {
                    Assets selectedAsset = _assetRepository.GetAssetByID(softwareAssetModel.AssetID);
                    if (selectedAsset != null)
                    {
                        selectedAsset.AssetName     = softwareAssetModel.AssetName;
                        selectedAsset.SerialNumber  = softwareAssetModel.SerialNumber;
                        selectedAsset.AssetTypeID   = softwareAssetModel.AssetTypeID;
                        selectedAsset.AssetStatusID = (int)AssetTrackingStatus.New;
                    }
                    _assetRepository.UpdateAsset(selectedAsset);

                    _softwareAssetService.UpdateSoftwareAsset(softwareAssetModel);

                    if (softwareAssetModel.ComponentAssetMapping != null)
                    {
                        if (softwareAssetModel.ComponentAssetMapping.Where(fet => fet.ComponentID != 0).ToList().Count > 0)
                        {
                            foreach (var item in softwareAssetModel.ComponentAssetMapping.Where(fet => fet.ComponentID != 0).ToList())
                            {
                                item.AssignedAssetID   = selectedAsset.ID;
                                item.ActualAssetID     = selectedAsset.ID;
                                item.AssignedDate      = DateTime.Now;
                                item.AssignedBy        = GetLoginEmployeeId();
                                item.ComponentStatusId = (int)ComponentTrackingStatus.Assign;
                                _componentAssetMappingService.UpdateComponentAssetMapping(item);
                                ComponentTrackerModel componentTrackerModel = new ComponentTrackerModel
                                {
                                    AssetID           = selectedAsset.ID,
                                    ComponentID       = item.ComponentID,
                                    ComponentStatusID = (int)ComponentTrackingStatus.Assign,
                                    CreatedBy         = GetLoginEmployeeId(),
                                    CreatedDate       = DateTime.Now
                                };
                                _componentTrackerService.CreateComponentTracker(componentTrackerModel);
                            }
                        }
                    }
                    scope.Complete();
                    return(softwareAssetModel);
                }
                catch (Exception)
                {
                    scope.Dispose();
                    throw;
                }
            }
        }
コード例 #2
0
ファイル: AssetService.cs プロジェクト: ravibharathim/AMS_02
        public SoftwareAssetModel UpdateSoftwareAsset(SoftwareAssetModel softwareAssetModel)
        {
            Assets selectedAsset = _assetRepository.GetAssetByID(softwareAssetModel.AssetID);

            if (selectedAsset != null)
            {
                selectedAsset.AssetName     = softwareAssetModel.AssetName;
                selectedAsset.SerialNumber  = softwareAssetModel.SerialNumber;
                selectedAsset.AssetTypeID   = softwareAssetModel.AssetTypeID;
                selectedAsset.AssetStatusID = (int)AssetTrackingStatus.New;
            }
            _assetRepository.UpdateAsset(selectedAsset);

            _softwareAssetService.UpdateSoftwareAsset(softwareAssetModel);

            if (softwareAssetModel.ComponentAssetMapping != null)
            {
                if (softwareAssetModel.ComponentAssetMapping.Where(fet => fet.Mandatory == true || fet.ComponentID != 0).ToList().Count > 0)
                {
                    foreach (var item in softwareAssetModel.ComponentAssetMapping.Where(fet => fet.Mandatory == true || fet.ComponentID != 0).ToList())
                    {
                        item.AssignedAssetID   = selectedAsset.ID;
                        item.ActualAssetID     = selectedAsset.ID;
                        item.AssignedDate      = DateTime.Now;
                        item.AssignedBy        = GetLoginEmployeeId();
                        item.ComponentStatusId = (int)ComponentTrackingStatus.Assign;
                        _componentAssetMappingService.UpdateComponentAssetMapping(item);
                        ComponentTrackerModel componentTrackerModel = new ComponentTrackerModel
                        {
                            AssetID           = selectedAsset.ID,
                            ComponentID       = item.ComponentID,
                            ComponentStatusID = (int)ComponentTrackingStatus.Assign,
                            CreatedBy         = GetLoginEmployeeId(),
                            CreatedDate       = DateTime.Now
                        };
                        _componentTrackerService.CreateComponentTracker(componentTrackerModel);
                    }
                }
            }
            return(softwareAssetModel);
        }