Пример #1
0
        public int Save(ShortModel shortUrl)
        {
            _context.ShortUrls.Add(shortUrl);
            _context.SaveChanges();

            return(shortUrl.Id);
        }
Пример #2
0
        public void ShortIsNotValid()
        {
            var model = new ShortModel()
            {
                Value = default(short)
            };

            Assert.Throws <AggregateValidationException>(() => ExtendedValidator.EnsureIsValid(model));
        }
Пример #3
0
        public void ShortIsValid()
        {
            var model = new ShortModel()
            {
                Value = (short)5
            };

            ExtendedValidator.EnsureIsValid(model);
        }
Пример #4
0
        public IActionResult Create(string mainUrl)
        {
            var shortUrl = new ShortModel
            {
                MainUrl = mainUrl
            };

            _service.Save(shortUrl);

            return(RedirectToAction(actionName: nameof(Show), routeValues: new { id = shortUrl.Id }));
        }
Пример #5
0
 public void ShortIsValid()
 {
     var model = new ShortModel() { Value = (short)5 };
     ExtendedValidator.EnsureIsValid(model);
 }
Пример #6
0
 public void ShortIsNotValid()
 {
     var model = new ShortModel() { Value = default(short) };
     Assert.Throws<AggregateValidationException>(() => ExtendedValidator.EnsureIsValid(model));
 }