Exemplo n.º 1
0
        public JsonResult Delete(int id)
        {
            var entity = _service.Load(id);
            var result = _service.Delete(entity, AppUser);

            return(Json(result));
        }
Exemplo n.º 2
0
        public bool Delete(string id)
        {
            bool asset = m_localService.Delete(id);

            if (!asset)
            {
                asset = m_remoteService.Delete(id);
            }
            return(asset);
        }
Exemplo n.º 3
0
    public void DeleteOption()
    {
        string assetGuid = CategoryAssets[CategoryDropdown.value].AssetGuid;
        string assetPath = Path.Combine(Config.PersistentDataPath, CategoryType.ToString() + "s", assetGuid); // TODO align types with path

        Service.Delete(assetGuid);
        if (File.Exists(assetPath))
        {
            File.Delete(assetPath);
        }
        RefreshOptions();
    }
Exemplo n.º 4
0
        public void TestDefaultRiskCalculationOnAsset()
        {
            var riskType = _companyService.CreateRiskType(new RiskType()
            {
                Name = "Test"
            });
            var asset  = CreateAsset();
            var threat = CreateThreat();

            asset.Threats.Add(threat);
            var createdAsset = _assetService.Create(asset);

            Assert.IsTrue(createdAsset.Risks.Any(r => r.Type == riskType.RiskTypeId));
            var assetRisk = createdAsset.Risks[0];

            Assert.IsTrue(createdAsset.Threats.Count == 1);
            Assert.IsTrue(createdAsset.Threats[0].Risks.Any(r => r.Type == riskType.RiskTypeId));
            var threatRisk = createdAsset.Threats[0].Risks[0];

            Assert.IsTrue(assetRisk.Equals(threatRisk));
            _assetService.Delete(createdAsset.AssetId);
            _assetService.Delete(riskType.RiskTypeId);
        }
        public void Delete_Book_ReturnsTrue()
        {
            var book = new Book()
            {
                id = 1, name = "Java", author = "Guido", edition = "1st", price = 1000
            };

            var service = new AssetService <Book>(new MockRepository <Book>());

            service.Add(book);

            var expected = service.Delete(book.id);

            Assert.False(expected == null);
        }
Exemplo n.º 6
0
        public void Delete_Hardware_ReturnsTrue()
        {
            var hardware = new Hardware()
            {
                id = 1, name = "laptop", brand = "hp", model = "hp231", price = 10000
            };

            var service = new AssetService <Hardware>(new MockRepository <Hardware>());

            service.Add(hardware);

            var expected = service.Delete(hardware.id);

            Assert.False(expected == null);
        }
Exemplo n.º 7
0
        public void Delete_Software_ReturnsTrue()
        {
            var software = new Software()
            {
                id = 1, name = "Antivirus", provider = "Avast", version = "av1", price = 1500
            };

            var service = new AssetService <Software>(new MockRepository <Software>());

            service.Add(software);

            var expected = service.Delete(software.id);

            Assert.False(expected == null);
        }
        /// <summary>
        /// Selects the custom sound.
        /// </summary>
        public void SelectCustomSound()
        {
            if (!this.HasCustomTradeSound)
            {
                try
                {
                    if (this._currentTradeAlert != null)
                    {
                        this._currentTradeAlert.Stop();
                        this._currentTradeAlert = null;
                    }

                    AssetService.Delete(SoundService.TradeAlertFileName);
                }
                catch
                {
                    // Sound was playing.
                    this.HasCustomTradeSound = true;
                }

                return;
            }

            var openFileDialog = new OpenFileDialog
            {
                Filter = "MP3 files (*.mp3)|*.mp3",
            };

            if (openFileDialog.ShowDialog() == true)
            {
                var fileName = openFileDialog.FileName;
                if (!File.Exists(fileName))
                {
                    return;
                }

                var content = File.ReadAllBytes(fileName);
                AssetService.Create(SoundService.TradeAlertFileName, content);
            }
            else
            {
                this.HasCustomTradeSound = false;
            }
        }
Exemplo n.º 9
0
    public void DeleteOption()
    {
        if (SimulationsData != null)
        {
            SimulationService.Delete(SimulationsData[CategoryDropdown.value]);
            RefreshSimulationsOptions();
        }
        else
        {
            string assetGuid = CategoryAssets[CategoryDropdown.value].AssetGuid;
            string assetPath = Path.Combine(Config.PersistentDataPath, CategoryType.ToString() + "s", assetGuid); // TODO align types with path
            Service.Delete(assetGuid);
            if (File.Exists(assetPath))
            {
                File.Delete(assetPath);
            }
            RefreshOptions();
        }

        ConnectionUI.instance.UpdateDropdown();
    }
Exemplo n.º 10
0
 public IHttpActionResult Delete(int id)
 {
     AssetService.Delete(id);
     return(Ok());
 }
Exemplo n.º 11
0
        public static Task <AssetModel> GetAsset(BundleConfig.BundleTypes type, string assetGuid, string name = null,
                                                 IProgress <Tuple <string, float> > progressCallback          = null)
        {
            Init();
            var assetService = new AssetService();
            var found        = assetService.Get(assetGuid);

            if (found != null)
            {
                if (File.Exists(found.LocalPath))
                {
                    return(Task.FromResult(found));
                }
                else
                {
                    Debug.Log($"removing stale entry from assetService due to missing file: {found.LocalPath}");
                    assetService.Delete(assetGuid);
                }
            }

            var typeString = BundleConfig.singularOf(type);

            if (name == null)
            {
                name = typeString;
            }

            string localPath = WebUtilities.GenerateLocalPath(assetGuid, type);

            Uri uri = new Uri(Config.CloudUrl + "/api/v1/assets/download/bundle/" + assetGuid);

            var progressState = new Tuple <string, float>(name, 0.0f);

            progressCallback?.Report(new Tuple <string, float>(name, 0.0f));
            Debug.Log($"{name} Download at 0%");
            var t = new TaskCompletionSource <AssetModel>();

            downloads.Enqueue(new Download(uri, localPath,
                                           progress =>
            {
                progressCallback?.Report(new Tuple <string, float>(name, progress));
                Debug.Log($"{name} Download at {progress}%");
            },
                                           (success, ex) => {
                if (success)
                {
                    try
                    {
                        var model = new AssetModel()
                        {
                            AssetGuid = assetGuid,
                            Type      = typeString,
                            Name      = name,
                            LocalPath = localPath,
                            DateAdded = DateTime.UtcNow.ToString()
                        };
                        assetService.Add(model);
                        Debug.Log($"{name} Download Complete.");
                        progressCallback?.Report(new Tuple <string, float>(name, 100));
                        t.TrySetResult(model);
                    }
                    catch (Exception e)
                    {
                        t.TrySetException(e);
                    }
                }
                else
                {
                    t.TrySetException(ex);
                }
            }));
            return(t.Task);
        }