Exemple #1
0
        // GET: NameCheck
        public ActionResult Index()
        {
            var viewModel = new NameCheckViewModel();

            viewModel.History = ReadOrCreateSessionItem <List <NameCheckModel> >(Constants.SessionKeys.NameCheckHistory);
            return(View(viewModel));
        }
Exemple #2
0
        public async Task <ActionResult> Index(NameCheckViewModel viewModel)
        {
            if (viewModel == null)
            {
                return(RedirectToAction("index"));
            }

            viewModel.History = ReadOrCreateSessionItem <List <NameCheckModel> >(Constants.SessionKeys.NameCheckHistory);

            if (ModelState.IsValid)
            {
                NameCheckModel model = await Provider.NameCheckAsync(viewModel.Name, EndpointType.Website, Request.UserHostAddress);

                await NameCheckDataService.SaveAsync(model);

                viewModel.History.Add(model);
                SaveOrCreateSessionItem(Constants.SessionKeys.NameCheckHistory, viewModel.History);
                viewModel.Name = null;
                ModelState.Clear();
            }

            return(View(viewModel));
        }