public void RemoveArtifact([FromBody] RemoveArtifactRequestModel requestModel)
        {
            var existingArtifact = Context.Artifacts.Include(r => r.Permissions).FirstOrDefault(r => r.ArtifactId == requestModel.ArtifactId);

            if (existingArtifact != null)
            {
                Context.Artifacts.Remove(existingArtifact);
                Context.SaveChanges();
            }
        }
示例#2
0
        public void RemoveArtifact_Successful()
        {
            // Given
            var resources    = new Resources();
            var requestModel = new RemoveArtifactRequestModel {
                ArtifactId = 1
            };

            resources.MockApiCaller.AddMockResponse("WebApi:Permissions:RemoveArtifact", requestModel, "Success");

            // When
            var result = resources.Controller.RemoveArtifact(requestModel) as JsonResult;

            // Then
            Assert.IsNotNull(result);
            Assert.AreEqual("Success", result.Value.ToString());
        }
        public void RemoveArtifact()
        {
            var resources = new Resources();

            using (resources.DbContext.Database.BeginTransaction())
            {
                // Given
                var artifact     = TestHelper.CreateArtifact(resources.DbContext);
                var requestModel = new RemoveArtifactRequestModel {
                    ArtifactId = artifact.ArtifactId
                };

                // When
                resources.GuiController.RemoveArtifact(requestModel);

                // Then
                var savedArtifact = resources.DbContext.Artifacts.FirstOrDefault(r => r.ArtifactId == requestModel.ArtifactId);
                Assert.IsNull(savedArtifact);
            }
        }
        public JsonResult RemoveArtifact(RemoveArtifactRequestModel requestModel)
        {
            WebApiCaller.PostAsync <string>("WebApi:Permissions:RemoveArtifact", requestModel);

            return(Json("Success"));
        }