public int Save(ShortModel shortUrl) { _context.ShortUrls.Add(shortUrl); _context.SaveChanges(); return(shortUrl.Id); }
public void ShortIsNotValid() { var model = new ShortModel() { Value = default(short) }; Assert.Throws <AggregateValidationException>(() => ExtendedValidator.EnsureIsValid(model)); }
public void ShortIsValid() { var model = new ShortModel() { Value = (short)5 }; ExtendedValidator.EnsureIsValid(model); }
public IActionResult Create(string mainUrl) { var shortUrl = new ShortModel { MainUrl = mainUrl }; _service.Save(shortUrl); return(RedirectToAction(actionName: nameof(Show), routeValues: new { id = shortUrl.Id })); }
public void ShortIsNotValid() { var model = new ShortModel() { Value = default(short) }; Assert.Throws<AggregateValidationException>(() => ExtendedValidator.EnsureIsValid(model)); }