예제 #1
0
        public IHttpActionResult Get()
        {
            ArtifactService service   = CreateArtifactService();
            var             artifacts = service.GetArtifacts();

            return(Ok(artifacts));
        }
예제 #2
0
        private ArtifactService CreateArtifactService()
        {
            var userID          = Guid.Parse(User.Identity.GetUserId());
            var artifactService = new ArtifactService(userID);

            return(artifactService);
        }
예제 #3
0
        public IHttpActionResult Get(int id)
        {
            ArtifactService service  = CreateArtifactService();
            var             artifact = service.GetArtifactByID(id);

            return(Ok(artifact));
        }
예제 #4
0
        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));
        }
예제 #5
0
        // GET: Artifact
        public ActionResult ArtifactIndex()
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new ArtifactService(userId);
            var model   = service.GetArtifact();

            return(View(model));
        }
예제 #6
0
        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));
        }
예제 #7
0
        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"));
        }
예제 #8
0
        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);
        }
예제 #9
0
        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"));
        }
예제 #10
0
        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>()));
        }
예제 #11
0
        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>()));
        }
예제 #12
0
        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));
        }
예제 #13
0
        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>()));
        }
예제 #14
0
        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>()));
        }
예제 #15
0
        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>()));
        }
예제 #16
0
 public CreateTenantCommandHandler(TableauService tableauService, SnowflakeService snowflakeService, ArtifactService artifactService)
 {
     _tableauService   = tableauService;
     _snowflakeService = snowflakeService;
     _artifactService  = artifactService;
 }
예제 #17
0
 public void Setup()
 {
     _fixture         = new Fixture();
     _artifactRepo    = Substitute.For <IArtifactRepository>();
     _artifactService = new ArtifactService(_artifactRepo);
 }
예제 #18
0
 public void  Initialize()
 {
     RuneService.Initialize();
     PotionService.Initialize();
     ArtifactService.Initialize();
 }