Beispiel #1
0
        public int CreateAssetTracker(AssetTrackerModel assetTrackerModel)
        {
            AssetTracker assetTracker = null;

            assetTracker = this._assetTrackerRepository.CreateAssetTracker(new AssetTracker()
            {
                AssetID       = assetTrackerModel.AssetID,
                EmpID         = assetTrackerModel.EmpID,
                AssetStatusID = assetTrackerModel.AssetStatusID,
                CreatedDate   = assetTrackerModel.CreatedDate,
                CreatedBy     = assetTrackerModel.CreatedBy,
                Remarks       = assetTrackerModel.Remarks,
            });
            return(assetTracker.ID);
        }
Beispiel #2
0
        public HardwareAssetModel CreateHardwareAsset(HardwareAssetModel hardwareAssetModel)
        {
            using (var scope = new TransactionScope(TransactionScopeOption.Required))
            {
                try
                {
                    Assets assets = new Assets
                    {
                        AssetName     = hardwareAssetModel.AssetName,
                        SerialNumber  = hardwareAssetModel.SerialNumber,
                        AssetTypeID   = hardwareAssetModel.AssetTypeID,
                        AssetStatusID = (int)AssetTrackingStatus.New,
                        CreatedDate   = DateTime.Now,
                        CreatedBy     = GetLoginEmployeeId()
                    };
                    var createdAsset = _assetRepository.CreateAsset(assets);

                    hardwareAssetModel.AssetID = createdAsset.ID;
                    _hardwareAssetService.CreateHardwareAsset(hardwareAssetModel);

                    AssetTrackerModel assetTrackerModel = new AssetTrackerModel
                    {
                        AssetID       = hardwareAssetModel.AssetID,
                        AssetStatusID = (int)AssetTrackingStatus.New,
                        CreatedDate   = DateTime.Now,
                        CreatedBy     = assets.CreatedBy,
                        Remarks       = hardwareAssetModel.Comment,
                    };
                    _assetTrackerService.CreateAssetTracker(assetTrackerModel);

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

                    scope.Complete();
                    return(hardwareAssetModel);
                }
                catch (Exception)
                {
                    scope.Dispose();
                    throw;
                }
            }
        }