コード例 #1
0
        public void AccountPage_WhenTempDataHasObject_ReturnsPageViewWithObject()
        {
            var model = new PageRegistration();

            _controller.TempData[model.GetType().FullName] = model;

            var result = _controller.AccountPage("aPageShortName");

            Assert.That((result), Is.TypeOf<ViewResult>());
            Assert.That(((ViewResult)result).ViewName, Is.EqualTo("Page"));
            Assert.That(((ViewResult)result).Model, Is.EqualTo(model));
        }
コード例 #2
0
        public ActionResult Create(PageRegistration pageRegistration)
        {
            if (!ModelState.IsValid)
            {
                return View(pageRegistration);
            }

            if (pageRegistration.Image.IsDefault)
            {
                var entity = _userImagesService.GetUsersDefaultImage();

                if (entity.IsDefault == false)
                {
                    entity = _userImagesService.GetUserImageEntityByUrl(pageRegistration.Image.Url);
                    entity.IsDefault = true;
                }
                else
                {
                    entity.Url = pageRegistration.Image.Url;
                }

                _userImagesService.SaveUserImageEntity(entity);
            }

            var response = _apiClient.CreatePage(pageRegistration);

            if (!response.Successful)
            {
                ModelState.AddModelError("General", Resources.CreateController_Create_Oooops);
                return View(pageRegistration);
            }

            _imageCleanup.BeginInvoke(null, null);

            _apiClient.GetPagesAsync(_currentUserSession.EmailAddress, _currentUserSession.UpdatePages);
            pageRegistration.LoginTokenForEua = response.LoginTokenForEua;
            pageRegistration.PageId = response.PageId;
            pageRegistration.Domain = response.Domain;

            TempData[pageRegistration.GetType().FullName] = pageRegistration;

            return RedirectToAction("AccountPage", "Account", new { @pageShortName = pageRegistration.PageShortName });
        }