private void PopulateTable(int numberOfRecords)
 {
     for (int i = 0; i < numberOfRecords; i++)
     {
         _redirectService.Add(new RedirectRule {
             SourceUrl      = "sourceUrl" + i.ToString(),
             DestinationUrl = "destinationUrl" + i.ToString(),
             IsPermanent    = i % 2 == 0
         });
     }
 }
        public ActionResult AddPost()
        {
            var redirect = new RedirectRule();

            //thanks to the _includeProperties, Update succeeds even if we are not adding the id from UI
            if (!TryUpdateModel(redirect, _includeProperties))
            {
                _orchardServices.TransactionManager.Cancel();
                return(View(redirect));
            }
            return(Validate(redirect, (red) => _redirectService.Add(red)));
        }
Example #3
0
        public void Import(
            long createdDateTimeTick,
            string sourceUrl,
            string destinationUrl,
            bool isPermanent)
        {
            var result = _redirectService.GetTable().FirstOrDefault(x => x.SourceUrl == sourceUrl);

            if (result == null)
            {
                _redirectService.Add(new RedirectRule {
                    CreatedDateTime = new DateTime(createdDateTimeTick),
                    SourceUrl       = sourceUrl,
                    DestinationUrl  = destinationUrl,
                    IsPermanent     = isPermanent
                });
            }
        }