示例#1
0
        public ActionResult Index(CreateTorrentWidgetModel model)
        {
            if (!_modelStateValidatorService.Validate(ModelState, model))
            {
                // quick solution to populate genres when invalid data is passed on Add torrent
                var genres = _taxonomyService.GetTaxonNamesByTaxonomy(Constants.GenresTaxonomyName);
                model.Genres = genres;
                return(View(model));
            }

            StringBuilder sb = new StringBuilder();

            try
            {
                CreateTorrentDto torrent = DtoCreator.CreateTorrent(model);
                _torrentService.CreateTorrentWithPublish(torrent);

                sb.AppendLine(string.Format(Constants.CreateTorrentSuccessMessage, model.Title));
                TempData.Add(Constants.SuccessMessageKey, sb.ToString());
            }
            catch (Exception exc)
            {
                sb.AppendLine(exc.Message);

                if (exc.InnerException != null)
                {
                    sb.AppendLine(exc.InnerException.Message);
                }

                TempData.Add(Constants.ErrorMessageKey, sb.ToString());
            }

            return(RedirectToAction(nameof(CreateTorrentWidgetController.Index)));
        }
        public void AdvancedDataCore_AcceptChanges( )
        {
            Queue <Change>       changes = new Queue <Change>( );
            ITestInterfaceAdcNpc dto     = DtoCreator.New <ITestInterfaceAdcNpc>( );

            dto.PropertyChanged += (sender, args) => {
                changes.Enqueue(
                    GetChange(dto, args.PropertyName));
            };

            dto.Prop = 42;
            dto.Prop = 23;
            dto.AcceptChanges( );

            Assert.AreEqual(4, changes.Count);

            Change change = changes.Dequeue( );

            Assert.AreEqual(nameof(ITestInterfaceAdcNpc.HasChanges), change.PropertyName);
            Assert.AreEqual(true, change.Value);

            change = changes.Dequeue( );
            Assert.AreEqual(nameof(ITestInterfaceAdcNpc.Prop), change.PropertyName);
            Assert.AreEqual(42, change.Value);

            change = changes.Dequeue( );
            Assert.AreEqual(nameof(ITestInterfaceAdcNpc.Prop), change.PropertyName);
            Assert.AreEqual(23, change.Value);

            change = changes.Dequeue( );
            Assert.AreEqual(nameof(ITestInterfaceAdcNpc.HasChanges), change.PropertyName);
            Assert.AreEqual(false, change.Value);
        }
        public void SimpleDataCore( )
        {
            Queue <Change>       changes = new Queue <Change>( );
            ITestInterfaceSdcNpc dto     = DtoCreator.New <ITestInterfaceSdcNpc>( );

            dto.PropertyChanged += (sender, args) => {
                changes.Enqueue(
                    GetChange(dto, args.PropertyName));
            };

            dto.Prop = 42;
            dto.Prop = 23;
            dto.MarkNotDirty( );

            Assert.AreEqual(4, changes.Count);

            Change change = changes.Dequeue( );

            Assert.AreEqual(nameof(ITestInterfaceSdcNpc.IsDirty), change.PropertyName);
            Assert.AreEqual(true, change.Value);

            change = changes.Dequeue( );
            Assert.AreEqual(nameof(ITestInterfaceSdcNpc.Prop), change.PropertyName);
            Assert.AreEqual(42, change.Value);

            change = changes.Dequeue( );
            Assert.AreEqual(nameof(ITestInterfaceSdcNpc.Prop), change.PropertyName);
            Assert.AreEqual(23, change.Value);

            change = changes.Dequeue( );
            Assert.AreEqual(nameof(ITestInterfaceSdcNpc.IsDirty), change.PropertyName);
            Assert.AreEqual(false, change.Value);
        }
        public IList <XpsDigitalSignature> GetDocumentSignatures(string documentId)
        {
            var actor           = HttpContext.GetTokenActor();
            var api             = _contextService.GetServerApi(actor);
            var guid            = Guid.Parse(documentId);
            var xpsServiceApi   = _contextService.GetExternalXpsServiceApi(api);
            var signatureBuffer = xpsServiceApi.GetSignatures(guid);

            return(DtoCreator.CreateDigitalSignatures(signatureBuffer));
        }
示例#5
0
        public void AdvancedDataCoreRevertTest( )
        {
            TAdc dto = DtoCreator.New <TAdc>( );

            dto.Prop = 42;
            dto.RevertChanges( );

            Assert.IsFalse(dto.HasChanges);
            Assert.IsNull(dto.Prop);
        }
示例#6
0
        public void AdvancedDataCoreAcceptTest( )
        {
            TAdc dto = DtoCreator.New <TAdc>( );

            dto.Prop = 42;
            dto.AcceptChanges( );

            Assert.AreEqual(42, dto.Prop);
            Assert.IsFalse(dto.HasChanges);
        }
示例#7
0
        public void SimpleDataCoreTest( )
        {
            TSdc dto = DtoCreator.New <TSdc>( );

            Assert.IsFalse(dto.IsDirty);
            Assert.IsNull(dto.Prop);

            dto.Prop = 42;

            Assert.AreEqual(42, dto.Prop);
            Assert.IsTrue(dto.IsDirty);
        }
示例#8
0
        public void AdvancedDataCoreTest( )
        {
            TAdc dto = DtoCreator.New <TAdc>( );

            Assert.IsFalse(dto.HasChanges);
            Assert.IsNull(dto.Prop);

            dto.Prop = 42;

            Assert.AreEqual(42, dto.Prop);
            Assert.IsTrue(dto.HasChanges);
        }
示例#9
0
        public void VersionedDataCoreTest( )
        {
            TVdc dto = DtoCreator.New <TVdc>( );

            Assert.IsNull(dto.Prop);
            Assert.IsFalse(dto.HasChanges);
            Assert.AreEqual(0, dto.CurrentVersion);

            dto.Prop = 42;

            Assert.AreEqual(42, dto.Prop);
            Assert.IsTrue(dto.HasChanges);
            Assert.AreEqual(1, dto.CurrentVersion);
        }
        public void VersionedDataCore_ResetToSquashed( )
        {
            Queue <Change>       changes = new Queue <Change>( );
            ITestInterfaceVdcNpc dto     = DtoCreator.New <ITestInterfaceVdcNpc>( );

            dto.PropertyChanged += (sender, args) => {
                changes.Enqueue(
                    GetChange(dto, args.PropertyName));
            };

            dto.Prop = 42;
            dto.Prop = 23;
            dto.ResetToSquashed( );

            Assert.AreEqual(8, changes.Count);

            Change change = changes.Dequeue( );

            Assert.AreEqual(nameof(ITestInterfaceVdcNpc.CurrentVersion), change.PropertyName);
            Assert.AreEqual(1, change.Value);

            change = changes.Dequeue( );
            Assert.AreEqual(nameof(ITestInterfaceVdcNpc.HasChanges), change.PropertyName);
            Assert.AreEqual(true, change.Value);

            change = changes.Dequeue( );
            Assert.AreEqual(nameof(ITestInterfaceVdcNpc.Prop), change.PropertyName);
            Assert.AreEqual(42, change.Value);

            change = changes.Dequeue( );
            Assert.AreEqual(nameof(ITestInterfaceVdcNpc.CurrentVersion), change.PropertyName);
            Assert.AreEqual(2, change.Value);

            change = changes.Dequeue( );
            Assert.AreEqual(nameof(ITestInterfaceVdcNpc.Prop), change.PropertyName);
            Assert.AreEqual(23, change.Value);

            change = changes.Dequeue( );
            Assert.AreEqual(nameof(ITestInterfaceVdcNpc.CurrentVersion), change.PropertyName);
            Assert.AreEqual(0, change.Value);

            change = changes.Dequeue( );
            Assert.AreEqual(nameof(ITestInterfaceVdcNpc.HasChanges), change.PropertyName);
            Assert.AreEqual(false, change.Value);

            change = changes.Dequeue( );
            Assert.AreEqual(nameof(ITestInterfaceVdcNpc.Prop), change.PropertyName);
            Assert.AreEqual(null, change.Value);
        }
示例#11
0
        public void AdvancedDataCoreRevertToAcceptedTest( )
        {
            TAdc dto = DtoCreator.New <TAdc>( );

            dto.Prop = 42;
            dto.AcceptChanges( );
            dto.Prop = 23;

            Assert.AreEqual(23, dto.Prop);
            Assert.IsTrue(dto.HasChanges);

            dto.RevertChanges( );

            Assert.AreEqual(42, dto.Prop);
            Assert.IsFalse(dto.HasChanges);
        }
示例#12
0
        public void VersionedDataCoreResetToVersionTest( )
        {
            TVdc dto = DtoCreator.New <TVdc>( );

            dto.Prop = 1;
            dto.Prop = 42;
            dto.Prop = 2;
            dto.Prop = 3;

            Assert.AreEqual(4, dto.CurrentVersion);

            dto.ResetToVersion(2);

            Assert.AreEqual(42, dto.Prop);
            Assert.IsTrue(dto.HasChanges);
            Assert.AreEqual(2, dto.CurrentVersion);
        }
示例#13
0
        public void VersionedDataCoreResetToSquashedTest( )
        {
            TVdc dto = DtoCreator.New <TVdc>( );

            dto.Prop = 1;
            dto.Prop = 42;

            dto.SquashChanges( );

            dto.Prop = 2;
            dto.Prop = 3;

            dto.ResetToSquashed( );

            Assert.AreEqual(42, dto.Prop);
            Assert.IsFalse(dto.HasChanges);
            Assert.AreEqual(2, dto.CurrentVersion);
        }
示例#14
0
        public async Task <IEnumerable <PracticeDto> > GetPractices()
        {
            //var filter = Builders<Practice>.Filter.AnyEq("DoctorAvaliable", new ObjectId ( "5bc8f2c21c9d440000a98282" ));
            //var result = await _context.PracticeCollection
            //    .Find(filter)
            //    .ToListAsync();

            practiceDtoList.Clear();

            var result = await _context.PracticeCollection
                         .Find(_ => true).ToListAsync();

            foreach (var _practice in result)
            {
                practiceDtoList.Add(DtoCreator.CreatePracticeDto(_practice));
            }

            return(practiceDtoList);
        }