ViewModel for the AccessToken class
Beispiel #1
0
        public ActionResult Create(AccessToken accessToken)
        {
            var accessTokenToCreate = new AccessToken();

            Mapper.Map(accessToken, accessTokenToCreate);

            accessTokenToCreate.SetNewToken();

            accessTokenToCreate.TransferValidationMessagesTo(ModelState);

            if (ModelState.IsValid)
            {
                _accessTokenRepository.EnsurePersistent(accessTokenToCreate);

                Message = "AccessToken Created Successfully";

                return(RedirectToAction("Details", new { id = accessTokenToCreate.Id }));
            }
            else
            {
                var viewModel = AccessTokenViewModel.Create(Repository);
                viewModel.AccessToken = accessToken;

                return(View(viewModel));
            }
        }
Beispiel #2
0
        public static AccessTokenViewModel Create(IRepository repository)
        {
            Check.Require(repository != null, "Repository must be supplied");

            var viewModel = new AccessTokenViewModel
            {
                AccessToken  = new AccessToken(),
                Applications = repository.OfType <Application>().Queryable.OrderBy(x => x.Name).ToList()
            };

            return(viewModel);
        }
        public static AccessTokenViewModel Create(IRepository repository)
        {
            Check.Require(repository != null, "Repository must be supplied");

            var viewModel = new AccessTokenViewModel
                                {
                                    AccessToken = new AccessToken(),
                                    Applications = repository.OfType<Application>().Queryable.OrderBy(x => x.Name).ToList()
                                };

            return viewModel;
        }
Beispiel #4
0
        //
        // GET: /AccessToken/Create
        public ActionResult Create()
        {
            var viewModel = AccessTokenViewModel.Create(Repository);

            return(View(viewModel));
        }