public IHttpActionResult Get() { ArtifactService service = CreateArtifactService(); var artifacts = service.GetArtifacts(); return(Ok(artifacts)); }
private ArtifactService CreateArtifactService() { var userID = Guid.Parse(User.Identity.GetUserId()); var artifactService = new ArtifactService(userID); return(artifactService); }
public IHttpActionResult Get(int id) { ArtifactService service = CreateArtifactService(); var artifact = service.GetArtifactByID(id); return(Ok(artifact)); }
public ActionResult ArtifactEdit(int id, ArtifactEdit model) { if (!ModelState.IsValid) { return(View(model)); } if (model.ArtifactID != id) { ModelState.AddModelError("", "Id Mismatch"); return(View(model)); } var userId = Guid.Parse(User.Identity.GetUserId()); var service = new ArtifactService(userId); if (service.UpdateArtifact(model)) { TempData["SaveResult"] = "Your Artifact was updated."; return(RedirectToAction("ArtifactIndex")); } ModelState.AddModelError("", "Your Artifact could not be updated."); return(View(model)); }
// GET: Artifact public ActionResult ArtifactIndex() { var userId = Guid.Parse(User.Identity.GetUserId()); var service = new ArtifactService(userId); var model = service.GetArtifact(); return(View(model)); }
public ActionResult Delete(int id) { var userId = Guid.Parse(User.Identity.GetUserId()); var service = new ArtifactService(userId); var model = service.GetArtifactById(id); return(View(model)); }
public ActionResult ArtifactDelete(int id) { var userId = Guid.Parse(User.Identity.GetUserId()); var service = new ArtifactService(userId); service.DeleteArtifact(id); TempData["SaveResult"] = "Your Artifact was deleted"; return(RedirectToAction("ArtifactIndex")); }
public TT2DataService(IDownloader client, ISettingManager settings) { WebClient = client; Settings = settings; Artifacts = new ArtifactService(GlobalSettings, WebClient); Equipment = new EquipmentService(GlobalSettings, WebClient); Pets = new PetService(GlobalSettings, WebClient); HelperSkills = new HelperSkillService(GlobalSettings, WebClient); Helpers = new HelperService(GlobalSettings, WebClient, HelperSkills); SkillTree = new SkillTreeService(GlobalSettings, WebClient); }
public ActionResult ArtifactCreate(ArtifactCreate model) { if (!ModelState.IsValid) { return(View(model)); } var userId = Guid.Parse(User.Identity.GetUserId()); var service = new ArtifactService(userId); service.CreateArtifact(model); return(RedirectToAction("ArtifactIndex")); }
public async void Get_null_record() { var mock = new ServiceMockFacade <IArtifactRepository>(); mock.RepositoryMock.Setup(x => x.Get(It.IsAny <string>())).Returns(Task.FromResult <Artifact>(null)); var service = new ArtifactService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.ArtifactModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLArtifactMapperMock, mock.DALMapperMockFactory.DALArtifactMapperMock); ApiArtifactResponseModel response = await service.Get(default(string)); response.Should().BeNull(); mock.RepositoryMock.Verify(x => x.Get(It.IsAny <string>())); }
public async void ByTenantId_Not_Exists() { var mock = new ServiceMockFacade <IArtifactRepository>(); mock.RepositoryMock.Setup(x => x.ByTenantId(It.IsAny <string>())).Returns(Task.FromResult <List <Artifact> >(new List <Artifact>())); var service = new ArtifactService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.ArtifactModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLArtifactMapperMock, mock.DALMapperMockFactory.DALArtifactMapperMock); List <ApiArtifactResponseModel> response = await service.ByTenantId(default(string)); response.Should().BeEmpty(); mock.RepositoryMock.Verify(x => x.ByTenantId(It.IsAny <string>())); }
public ActionResult ArtifactEdit(int id) { var userId = Guid.Parse(User.Identity.GetUserId()); var service = new ArtifactService(userId); var detail = service.GetArtifactById(id); var model = new ArtifactEdit { ArtifactID = detail.ArtifactID, ArtifactType = detail.ArtifactType, ShortLabel = detail.ShortLabel, Description = detail.Description, Link = detail.Link }; return(View(model)); }
public async void Create() { var mock = new ServiceMockFacade <IArtifactRepository>(); var model = new ApiArtifactRequestModel(); mock.RepositoryMock.Setup(x => x.Create(It.IsAny <Artifact>())).Returns(Task.FromResult(new Artifact())); var service = new ArtifactService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.ArtifactModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLArtifactMapperMock, mock.DALMapperMockFactory.DALArtifactMapperMock); CreateResponse <ApiArtifactResponseModel> response = await service.Create(model); response.Should().NotBeNull(); mock.ModelValidatorMockFactory.ArtifactModelValidatorMock.Verify(x => x.ValidateCreateAsync(It.IsAny <ApiArtifactRequestModel>())); mock.RepositoryMock.Verify(x => x.Create(It.IsAny <Artifact>())); }
public async void Delete() { var mock = new ServiceMockFacade <IArtifactRepository>(); var model = new ApiArtifactRequestModel(); mock.RepositoryMock.Setup(x => x.Delete(It.IsAny <string>())).Returns(Task.CompletedTask); var service = new ArtifactService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.ArtifactModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLArtifactMapperMock, mock.DALMapperMockFactory.DALArtifactMapperMock); ActionResponse response = await service.Delete(default(string)); response.Should().NotBeNull(); mock.RepositoryMock.Verify(x => x.Delete(It.IsAny <string>())); mock.ModelValidatorMockFactory.ArtifactModelValidatorMock.Verify(x => x.ValidateDeleteAsync(It.IsAny <string>())); }
public async void All() { var mock = new ServiceMockFacade <IArtifactRepository>(); var records = new List <Artifact>(); records.Add(new Artifact()); mock.RepositoryMock.Setup(x => x.All(It.IsAny <int>(), It.IsAny <int>())).Returns(Task.FromResult(records)); var service = new ArtifactService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.ArtifactModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLArtifactMapperMock, mock.DALMapperMockFactory.DALArtifactMapperMock); List <ApiArtifactResponseModel> response = await service.All(); response.Should().HaveCount(1); mock.RepositoryMock.Verify(x => x.All(It.IsAny <int>(), It.IsAny <int>())); }
public CreateTenantCommandHandler(TableauService tableauService, SnowflakeService snowflakeService, ArtifactService artifactService) { _tableauService = tableauService; _snowflakeService = snowflakeService; _artifactService = artifactService; }
public void Setup() { _fixture = new Fixture(); _artifactRepo = Substitute.For <IArtifactRepository>(); _artifactService = new ArtifactService(_artifactRepo); }
public void Initialize() { RuneService.Initialize(); PotionService.Initialize(); ArtifactService.Initialize(); }