Пример #1
0
        public async Task SaveChangesAsync_VerifyValidTVShowIsUpdated()
        {
            var              mockTMDBapi  = new Mock <ITMDBapi>();
            Movie            newMovie     = CommonTestFunctions.GetSampleTVShow(true);
            List <GenreType> SelectGenres = new List <GenreType>();

            SelectGenres.Add(GenreType.Romance);

            Context.Movie.Add(newMovie);
            Context.SaveChanges();

            using (var newcontext = new MarksMoviesContext(Options))
            {
                MovieDBAccess db      = new MovieDBAccess(newcontext);
                var           service = new EditService(db, mockTMDBapi.Object);

                var result = await service.SaveMovieAsync(newMovie, SelectGenres);

                Assert.IsTrue(result != 0);
            }
            using (var newcontext = new MarksMoviesContext(Options))
            {
                var movie = await newcontext.Movie.Include(g => g.Genres).SingleAsync();

                Assert.IsNotNull(movie);
                Assert.IsNotNull(movie.Genres);
                Assert.AreEqual(1, movie.Genres.Count);
            }
        }
Пример #2
0
        public async Task <Service> EditService(EditService serviceForEdit)
        {
            var service = await _context.Services.FindAsync(serviceForEdit.Id);

            if (service == null)
            {
                return(null);
            }

            service.Name               = serviceForEdit.Name;
            service.Recipient          = serviceForEdit.Recipient;
            service.Description        = serviceForEdit.Description;
            service.MileageReminder    = serviceForEdit.MileageReminder;
            service.MileageRule        = serviceForEdit.MileageRule;
            service.TimeReminder       = serviceForEdit.TimeReminder;
            service.TimeReminderEntity = serviceForEdit.TimeReminderEntity;
            service.TimeRule           = serviceForEdit.TimeRule;
            service.TimeRuleEntity     = serviceForEdit.TimeRuleEntity;
            service.BasedOn            = serviceForEdit.BasedOn;

            await _context.SaveChangesAsync();

            await NextServiceCalculation.CalculateNextService(service.Id, _context);

            return(this._mapper.Map <Data.Models.Service, Service>(service));
        }
Пример #3
0
        public void EditServiceTest()
        {
            // Arrange
            _dataAccessService.Setup(a => a.EditService(TestData.EditServices[0])).ReturnsAsync(TestData.Services[0]);
            IServiceBusinessService svc = new ServiceBusinessService(_dataAccessService.Object);
            var editService             = new EditService
            {
                BasedOn            = 0,
                Description        = "",
                MileageReminder    = 0,
                MileageRule        = 0,
                Name               = "Car Wash",
                Recipient          = "*****@*****.**",
                TimeReminder       = 2,
                TimeReminderEntity = 1,
                TimeRule           = 1,
                TimeRuleEntity     = 2,
            };

            // Act
            var actual = svc.EditService(editService);

            // Assert
            _dataAccessService.Verify(s => s.EditService(It.IsAny <DataAccessService.Models.EditService>()), Times.Once);
        }
Пример #4
0
 public ProfileModal(StorageService storage, CookieService cookie, ProfileService profile, EditService edit)
 {
     storageService = storage;
     cookieService  = cookie;
     profileService = profile;
     editService    = edit;
 }
Пример #5
0
        public async Task EditServiceTest()
        {
            // Arrange
            var serviceId         = TestData.Services[0].Id;
            var serviceController = ConfigureController();
            var editService       = new EditService
            {
                BasedOn            = 0,
                Description        = "",
                MileageReminder    = 0,
                MileageRule        = 0,
                Name               = "Car Wash",
                Recipient          = "*****@*****.**",
                TimeReminder       = 2,
                TimeReminderEntity = 1,
                TimeRule           = 1,
                TimeRuleEntity     = 2,
            };

            //// Act
            var actual = await serviceController.EditService(serviceId, editService);

            //// Assert
            Xunit.Assert.NotNull(actual);
            _serviceBusinessService.Verify(s => s.EditService(It.IsAny <BusinessService.Models.EditService>()), Times.Once);
        }
Пример #6
0
 public EventsController(
     ISearchService searchService,
     UserManager <User> userManager,
     EditService editService)
 {
     _searchService = searchService;
     _userManager   = userManager;
     _editService   = editService;
 }
        public void DeleteDiaryTest001()
        {
            mockRepository.Setup(x => x.Delete(1)).Returns(true);
            var service = new EditService(mockRepository.Object);

            var result = service.DeleteDiary(1);

            Assert.True(result);
        }
        public void DeleteDiaryTest002()
        {
            mockRepository.Setup(x => x.Delete(2)).Returns(false);
            var service = new EditService(mockRepository.Object);

            var result = service.DeleteDiary(2);

            Assert.False(result);
        }
Пример #9
0
 public EditViewModel()
 {
     _mainViewModel    = new MainViewModel();
     GoBackCommand     = new DelegateCommand <object>(GoBack);
     _model            = new EditService();
     _dishIng          = new ObservableCollection <Ingredient>();
     AddProductCommand = new DelegateCommand <object>(AddProduct);
     AddDishCommand    = new DelegateCommand <object>(AddDish);
     ClearAllCommand   = new DelegateCommand <object>(ClearAll);
 }
Пример #10
0
        /// <summary>
        /// Implement dispose to remove references.
        /// </summary>
        public void Dispose()
        {
            if (!string.IsNullOrWhiteSpace(id))
            {
                EditService.Unregister(id);
                id = string.Empty;
            }

            GC.SuppressFinalize(this);
        }
Пример #11
0
 public StatUnitsController(NSCRegDbContext context, StatUnitAnalysisRules statUnitAnalysisRules,
                            DbMandatoryFields mandatoryFields, ValidationSettings validationSettings)
 {
     _searchService  = new SearchService(context);
     _viewService    = new ViewService(context, mandatoryFields);
     _createService  = new CreateService(context, statUnitAnalysisRules, mandatoryFields, validationSettings, StatUnitTypeOfSave.WebApplication);
     _editService    = new EditService(context, statUnitAnalysisRules, mandatoryFields, validationSettings);
     _deleteService  = new DeleteService(context);
     _historyService = new HistoryService(context);
 }
Пример #12
0
        public void GetDiaryTest002()
        {
            var diaryList = new List <Diary>();

            mockRepository.Setup(x => x.Read(1)).Returns(diaryList);
            var service = new EditService(mockRepository.Object);

            var result = service.GetDiary(1);

            Assert.Null(result);
        }
Пример #13
0
        /// <summary>
        /// After rendering, hook up the interop.
        /// </summary>
        /// <param name="firstRender">A value indicating whether it is the first render.</param>
        /// <returns>The asynchronous task.</returns>
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            if (firstRender)
            {
                id = await EditService.RegisterTextAsync(
                    Text,
                    this);
            }

            await base.OnAfterRenderAsync(firstRender);
        }
Пример #14
0
        private void btnEdit_Click_1(object sender, EventArgs e)
        {
            // gọi api lấy dữ liệu theo mã

            using (EditService edit = new EditService(Convert.ToInt32(txtService.Text)))
            {
                edit.ShowDialog();
            }
            dgvDichVu.DataSource = GetAll();
            BindingData();
        }
Пример #15
0
        public static DataSourcesQueueService CreateEmptyConfiguredDataSourceQueueService(NSCRegDbContext ctx)
        {
            var analysisRules      = new StatUnitAnalysisRules();
            var dbMandatoryFields  = new DbMandatoryFields();
            var validationSettings = new ValidationSettings();
            var createSvc          = new CreateService(ctx, analysisRules, dbMandatoryFields, validationSettings, StatUnitTypeOfSave.WebApplication);
            var editSvc            = new EditService(ctx, analysisRules, dbMandatoryFields, validationSettings);
            var servicesConfig     = new ServicesSettings();

            return(new DataSourcesQueueService(ctx, createSvc, editSvc, servicesConfig, dbMandatoryFields));
        }
Пример #16
0
        private void AddScopedServices()
        {
            var dbContextHelper = new DbContextHelper();
            var ctx             = dbContextHelper.CreateDbContext(new string[] { });

            _queueSvc    = new QueueService(ctx);
            _analysisSvc = new AnalyzeService(ctx, _statUnitAnalysisRules, _dbMandatoryFields, _validationSettings);
            var createSvc = new CreateService(ctx, _statUnitAnalysisRules, _dbMandatoryFields, _validationSettings, StatUnitTypeOfSave.Service);
            var editSvc   = new EditService(ctx, _statUnitAnalysisRules, _dbMandatoryFields, _validationSettings);

            _saveManager = new SaveManager(ctx, _queueSvc, createSvc, editSvc);
        }
Пример #17
0
        public async Task SaveChangesAsync_VerifyNullMovieReturnsZero()
        {
            var              mockTMDBapi  = new Mock <ITMDBapi>();
            Movie            movie        = null;
            List <GenreType> SelectGenres = new List <GenreType>();

            var service = new EditService(DbAccess, mockTMDBapi.Object);

            var result = await service.SaveMovieAsync(movie, SelectGenres);

            Assert.AreEqual(0, result);
        }
Пример #18
0
 public EventManagementController(
     ISearchService searchService,
     DeletionService deletionService,
     CreationService creationService,
     EditService editService,
     IHostingEnvironment hostingEnvironment)
 {
     _searchService      = searchService;
     _deletionService    = deletionService;
     _creationService    = creationService;
     _editService        = editService;
     _hostingEnvironment = hostingEnvironment;
 }
Пример #19
0
        private void butEditService_Click(object sender, EventArgs e)
        {
            EditService edit = new EditService();

            edit.id.Text          = dataGridService.CurrentRow.Cells[0].Value.ToString();
            edit.textBname.Text   = dataGridService.CurrentRow.Cells[1].Value.ToString();
            edit.maskedPrize.Text = dataGridService.CurrentRow.Cells[2].Value.ToString();

            this.Hide();
            edit.ShowDialog();
            update();
            this.Show();
        }
Пример #20
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="expService"></param>
 /// <param name="editService"></param>
 /// <param name="deleteService"></param>
 /// <param name="createService"></param>
 /// <param name="detailService"></param>
 /// <param name="rankMoviesService"></param>
 public MediaController(ExportService expService,
                        EditService editService,
                        DeleteService deleteService,
                        CreateService createService,
                        DetailsService detailService,
                        RankMoviesService rankMoviesService)
 {
     _expService        = expService;
     _editService       = editService;
     _deleteService     = deleteService;
     _createService     = createService;
     _detailService     = detailService;
     _rankMoviesService = rankMoviesService;
 }
Пример #21
0
 public DataSourcesQueueService(NSCRegDbContext ctx,
                                CreateService createSvc,
                                EditService editSvc,
                                ServicesSettings config,
                                DbMandatoryFields dbMandatoryFields)
 {
     _dbContext             = ctx;
     _createSvc             = createSvc;
     _editSvc               = editSvc;
     _rootPath              = config.RootPath;
     _uploadDir             = config.UploadDir;
     _dbMandatoryFields     = dbMandatoryFields;
     _statUnitDeleteService = new DeleteService(ctx);
     _elasticService        = new ElasticService(ctx);
 }
Пример #22
0
        public void UpdateDiaryTest002()
        {
            var diary = new Diary(2, "たいとる更新その2(てすと)", "ほんぶん更新その2(てすと)");

            mockRepository.Setup(x => x.Update(It.Is <Diary>(x => x.id == 1))).Returns(false);
            var service       = new EditService(mockRepository.Object);
            var editViewModel = new EditViewModel()
            {
                Id = "2", Title = "たいとる更新その2(てすと)", Content = "ほんぶん更新その2(てすと)"
            };

            var result = service.UpdateDiary(editViewModel);

            Assert.False(result);
        }
Пример #23
0
        public void GetDiaryTest001()
        {
            var diaryList = new List <Diary>();

            diaryList.Add(new Diary(1, "たいとる(てすと)", "ほんぶん(てすと)"));
            mockRepository.Setup(x => x.Read(1)).Returns(diaryList);
            var service = new EditService(mockRepository.Object);

            var result = service.GetDiary(1);
            var model  = Assert.IsType <EditViewModel>(result);

            Assert.Equal("1", result.Id);
            Assert.Equal("たいとる(てすと)", result.Title);
            Assert.Equal("ほんぶん(てすと)", result.Content);
        }
Пример #24
0
    private bool HasTopic(EditService.AbsoluteTopicName[] topics, string name)
    {
      foreach (EditService.AbsoluteTopicName topic in topics)
      {
        if (topic.Name == name)
        {
          return true; 
        }
      }

      return false; 
    }
Пример #25
0
    private bool HasNamespace(EditService.ContentBase[] bases, string name)
    {
      foreach (EditService.ContentBase contentBase in bases)
      {
        if (contentBase.Namespace == name)
        {
          return true; 
        }
      }

      return false; 
    }
Пример #26
0
 public StorageViewModel()
 {
     _model         = new EditService();
     _mainViewModel = new MainViewModel();
     GoBackCommand  = new DelegateCommand <object>(GoBack);
 }
Пример #27
0
        private void BtnEdit_Click(object sender, RoutedEventArgs e)
        {
            EditService editServiceWindow = new EditService(service);

            editServiceWindow.Show();
        }
        public async Task <Service> EditService(EditService serviceForEdit)
        {
            var editedService = await this._serviceDataAccessService.EditService(this._mapper.Map <DataAccessService.Models.EditService>(serviceForEdit));

            return(_mapper.Map <Service>(editedService));
        }
Пример #29
0
        public async Task <IHttpActionResult> EditService([FromUri] string serviceId, [FromBody] EditService serviceForEdit)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.BadRequest(this.ModelState));
            }

            var service = await this._serviceBusinessService.GetById(serviceId);

            if (service == null)
            {
                return(this.BadRequest());
            }

            var businessServiceForEdit = this._mapper.Map <BusinessService.Models.EditService>(serviceForEdit);
            var editedService          = await this._serviceBusinessService.EditService(businessServiceForEdit);

            var apiService = this._mapper.Map <EditService>(editedService);

            return(this.Ok(apiService));
        }
Пример #30
0
 public AnalysisQueueService(NSCRegDbContext context, ViewService viewSvc, EditService editSvc)
 {
     _context = context;
     _viewSvc = viewSvc;
     _editSvc = editSvc;
 }
Пример #31
0
 public EditController()
 {
     this.service = new EditService();
 }