示例#1
0
        public IActionResult Add(UrlAddModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var shortUrl = TokenGenerator.GenerateShortUrl();

            var entity = new Main
            {
                Id          = Guid.NewGuid(),
                LongUrl     = model.LongUrl,
                EditableUrl = shortUrl,
                Date        = DateTime.Now
            };

            _uow.MainRepository.Add(entity);
            _uow.Commit();
            return(RedirectToAction("Index"));
        }
示例#2
0
        public IActionResult Add()
        {
            var model = new UrlAddModel();

            return(View(model));
        }