public void SetUp()
        {
            var mockRepo = new Mock <ISqlRepository <SonarrSettings> >();

            ExpectedLink = new SonarrSettings
            {
                Id              = 1,
                Enabled         = true,
                IpAddress       = "192",
                Port            = 25,
                ShowOnDashboard = true,
                ApiKey          = "abc"
            };
            ExpectedGetLinks = new List <SonarrSettings>
            {
                ExpectedLink,
            };


            mockRepo.Setup(x => x.GetAll()).Returns(ExpectedGetLinks).Verifiable();

            mockRepo.Setup(x => x.Get(1)).Returns(ExpectedLink).Verifiable();

            mockRepo.Setup(x => x.Update(It.IsAny <SonarrSettings>())).Returns(true).Verifiable();

            mockRepo.Setup(x => x.Insert(It.IsAny <SonarrSettings>())).Returns(1).Verifiable();


            MockRepo = mockRepo;
            Service  = new SonarrSettingsService(MockRepo.Object);
        }
        public ActionResult SonarrSettings(SonarrSettingsViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(viewModel));
            }

            var dto = new SonarrSettingsDto();

            dto.InjectFrom(viewModel);

            var result = SonarrSettingsService.SaveSettings(dto);

            if (result)
            {
                return(RedirectToAction("SonarrSettings"));
            }

            return(View("Error"));
        }