Exemple #1
0
        public int AssignAsset(AssetModel assetModel)
        {
            using (var scope = new TransactionScope(TransactionScopeOption.Required))
            {
                try
                {
                    EmployeeAssetMappingModel employeeAssetMappingModel = new EmployeeAssetMappingModel
                    {
                        EmployeeID = assetModel.EmployeeID,
                        AssetID    = assetModel.ID,
                        CreatedBy  = _employeeService.GetEmployeeByCorpId(HttpContext.Current.User.Identity.Name).ID
                    };

                    var employeeAssetMapping = _employeeAssetMappingRepository.CreateEmployeeAssetMapping(new EmployeeAssetMapping
                    {
                        AssetID     = assetModel.ID,
                        EmployeeID  = assetModel.EmployeeID,
                        CreatedDate = DateTime.Now,
                        // CreatedDate = assetModel.AssignDate,
                        CreatedBy = _employeeService.GetEmployeeByCorpId(HttpContext.Current.User.Identity.Name).ID,
                    });

                    if (employeeAssetMapping != null && employeeAssetMapping.ID != 0)
                    {
                        int id = _assetTrackerService.CreateAssetTracker(new AssetTrackerModel
                        {
                            AssetID       = assetModel.ID,
                            EmpID         = assetModel.EmployeeID,
                            AssetStatusID = (int)AssetTrackingStatus.Assign,
                            CreatedDate   = DateTime.Now,
                            CreatedBy     = employeeAssetMappingModel.CreatedBy,
                            Remarks       = assetModel.Remarks
                        });
                        if (id != 0)
                        {
                            assetModel.AssetStatusID = (int)AssetTrackingStatus.Assign;
                            id = UpdateAsset(assetModel);
                        }
                    }
                    scope.Complete();
                    return(assetModel.ID);
                }
                catch (Exception)
                {
                    scope.Dispose();
                    throw;
                }
            }
        }
Exemple #2
0
        public int AssignAsset(AssetModel assetModel)
        {
            EmployeeAssetMappingModel employeeAssetMappingModel = new EmployeeAssetMappingModel
            {
                EmployeeID = assetModel.EmployeeID,
                AssetID    = assetModel.ID,
                CreatedBy  = _employeeService.GetEmployeeByCorpId(HttpContext.Current.User.Identity.Name).ID
            };

            var employeeAssetMapping = _employeeAssetMappingRepository.CreateEmployeeAssetMapping(new EmployeeAssetMapping
            {
                AssetID     = assetModel.ID,
                EmployeeID  = assetModel.EmployeeID,
                CreatedDate = assetModel.AssignDate,
                CreatedBy   = _employeeService.GetEmployeeByCorpId(HttpContext.Current.User.Identity.Name).ID,
            });

            if (employeeAssetMapping != null && employeeAssetMapping.ID != 0)
            {
                int id = _assetTrackerService.CreateAssetTracker(new AssetTrackerModel
                {
                    AssetID       = assetModel.ID,
                    EmpID         = assetModel.EmployeeID,
                    AssetStatusID = (int)AssetTrackingStatus.Assign,
                    CreatedDate   = DateTime.Now,
                    CreatedBy     = employeeAssetMappingModel.CreatedBy,
                    Remarks       = assetModel.Remarks
                });
                if (id != 0)
                {
                    assetModel.AssetStatusID = (int)AssetTrackingStatus.Assign;
                    id = UpdateAsset(assetModel);
                }
            }


            return(assetModel.ID);
        }