private static void AssertCartContain(List<Order> expectedCart, PartialViewResult actualResult)
 {
     var actualCart = (List<Order>) actualResult.Model;
     Assert.Equal(expectedCart.Count, actualCart.Count);
     Assert.Equal(expectedCart[0], actualCart[0], new OrderComparer());
     Assert.Equal(expectedCart[1], actualCart[1], new OrderComparer());
 }
        public ActionResult CreateResult(ControllerContext controllerContext, ActionResult currentResult)
        {
            var viewResult = currentResult as ViewResult;

            if (viewResult == null)
                return null;

            var viewName = viewResult.ViewName.NullIfEmpty() 
                ?? controllerContext.RequestContext.RouteData.GetRequiredString("action");

            if (viewName.IsNullOrEmpty())
                throw new InvalidOperationException("View name cannot be null.");

            var partialViewName = string.Concat(partialViewPrefix, viewName);

            // check if partial exists, otherwise we'll use the same view
            var partialExists = viewResult.ViewEngineCollection.FindPartialView(controllerContext, partialViewName).View != null;

            var partialViewResult = new PartialViewResult
            {
                ViewData = viewResult.ViewData,
                TempData = viewResult.TempData,
                ViewName = partialExists ? partialViewName : viewName,
                ViewEngineCollection = viewResult.ViewEngineCollection,
            };

            return partialViewResult;
        }
 public ActionResult View2(string containerId)
 {
     PartialViewResult pr = new PartialViewResult(containerId);
     pr.RenderMode = RenderMode.AddTo;
     pr.Items = true;
     return pr;
 }
Esempio n. 4
0
 //
 // GET: /Product/
 //-------------------------------------- Contollers for ByManufactuer-----------------------------------------------------------
 public ActionResult FilterCategories(List<string> filterCategories)
 {
     var result = new PartialViewResult
                      {
                          ViewData = {Model = filterCategories}
                      };
     return result;
 }
 public override void OnResultExecuting(ResultExecutingContext filterContext)
 {
     PartialViewResult result = new PartialViewResult();
     result.ViewName = "PartialMessages";
     result.ViewData.Model = filterContext.Controller.ViewData["Messages"];
     result.ExecuteResult(filterContext.Controller.ControllerContext);
      			base.OnResultExecuting(filterContext);
 }
Esempio n. 6
0
 public ActionResult RenderCarriers(List<Carrier> carriers)
 {
     var result = new PartialViewResult()
     {
         ViewData = { Model = carriers }
     };
     return result;
 }
        /// <summary>
        /// Appends the content from a <see cref="PartialViewResult"/> to the elements
        /// matching a jQuery selector.
        /// </summary>
        public IAppendCommandToTargetSyntax AppendContent(PartialViewResult partialViewResult)
        {
            if (partialViewResult == null)
            throw new ArgumentNullException("partialViewResult");

              var commandBuilder = new AppendCommandBuilder(this);
              commandBuilder.SetContent(partialViewResult);
              return commandBuilder;
        }
        public void PrependPartialViewResultContentToElement_NullOrEmptyTargetSelector_ThrowsArgumentNullException(
      [Values(null, "")] string selector)
        {
            var partialViewResult = new PartialViewResult();

              Action action = () => Taconite.PrependContent(partialViewResult).To(selector);

              action.ShouldThrow<ArgumentNullException>();
        }
 public ActionResult View3(string containerId)
 {
     PartialViewResult pr = new PartialViewResult(containerId);
     pr.RenderMode = RenderMode.AddTo;
     pr.SingleControl = true;
     pr.ViewData["title"] = DateTime.Now.ToLongTimeString();
     pr.ViewData["html"] = DateTime.Now.ToLongTimeString();
     return pr;
 }
Esempio n. 10
0
        public ActionResult RenderDevices(List<PhoneDevice> devices)
        {
            var result = new PartialViewResult
            {
                ViewData = { Model = devices }
            };

            return result;
        }
        public void WithDefaultViewName_GivenExpectedValue_ShouldPass()
        {
            ActionResult result = new PartialViewResult
            {
                ViewName = String.Empty
            };

            result.Should().BePartialViewResult().WithDefaultViewName();
        }
        public void ModelAs_GivenExpectedValue_ShouldPass()
        {
            ActionResult result = new PartialViewResult
            {
                ViewData = new ViewDataDictionary("hello")
            };

            result.Should().BePartialViewResult().ModelAs<string>().Should().Be("hello");
        }
        public IInsertCommandBeforeOrAfterTargetSyntax InsertContent(PartialViewResult partialViewResult)
        {
            if (partialViewResult == null)
            throw new ArgumentNullException("partialViewResult");

              var commandBuilder = new InsertCommandBuilder(this);
              commandBuilder.SetContent(partialViewResult);
              return commandBuilder;
        }
        /// <summary>
        /// Assigns the <see cref="PartialViewResult"/> to append.
        /// </summary>
        public void SetContent(PartialViewResult partialViewResult)
        {
            if (partialViewResult == null)
            throw new ArgumentNullException("partialViewResult");

              if (_html != null)
            throw new InvalidOperationException("HTML content is already assigned.");

              _partialViewResult = partialViewResult;
        }
Esempio n. 15
0
        public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result)
        {
            PartialViewResult vr = new PartialViewResult();

            vr.ViewName = @"~/Views/Shared/Index.cshtml";

            result = vr;

            return true;
        }
        TaconiteResult IPluginCommandWithContentOrArgumentSyntax.WithContent(PartialViewResult partial)
        {
            if (partial == null)
            throw new ArgumentNullException("partial");

              var command = new ElementCommand(_plugin, _selector, partial);
              Result.AddCommand(command);

              return Result;
        }
        public void ModelAs_Null_ShouldFail()
        {
            ActionResult result = new PartialViewResult();
            string failureMessage = FailureMessageHelper.Format(FailureMessages.ViewResultBase_NullModel, typeof(Object).Name);

            Action a = () => result.Should().BePartialViewResult().ModelAs<Object>();

            a.ShouldThrow<Exception>()
                    .WithMessage(failureMessage);
        }
        public void ModelAs_GivenWrongType_ShouldFail()
        {
            ActionResult result = new PartialViewResult
            {
                ViewData = new ViewDataDictionary("hello")
            };

            Action a = () => result.Should().BePartialViewResult().ModelAs<int>().Should().Be(2);
            a.ShouldThrow<Exception>();
        }
        public void ModelAs_GivenUnexpectedValue_ShouldFail()
        {
            ActionResult result = new PartialViewResult
            {
                ViewData = new ViewDataDictionary("hello")
            };

            Action a = () => result.Should().BePartialViewResult().ModelAs<string>().Should().Be("xyx");
            a.ShouldThrow<Exception>();
        }
        public TaconiteResult WithContent(PartialViewResult partialViewResult)
        {
            if (partialViewResult == null)
            throw new ArgumentNullException("partialViewResult");

              var command = new ElementCommand("replaceContent", _selector, partialViewResult);
              Result.AddCommand(command);

              return Result;
        }
Esempio n. 21
0
        public ActionResult RenderDefaultSidebar()
        {
            var productCategories = Get_A_List_of_ProductCategories();

            var result = new PartialViewResult
                             {
                                 ViewData = {Model = productCategories}
                             };
            return result;
        }
 private void ErrorTest(PartialViewResult result)
 {
     Assert.IsNotNull(result);
     Assert.IsFalse(result.ViewData.ModelState.IsValid);
     var model = result.Model as HomeModel;
     Assert.AreEqual(null, model.AllNumbers);
     Assert.AreEqual(null, model.OddNumbers);
     Assert.AreEqual(null, model.EvenNumbers);
     Assert.AreEqual(null, model.SubstitutedNumbers);
     Assert.AreEqual(null, model.FibonacciNumbers);
 }
 public override void OnActionExecuted(ActionExecutedContext filterContext)
 {
     var vr = filterContext.Result as ViewResult;
     if (vr != null && filterContext.HttpContext.Request.IsAjaxRequest())
     {
         var pv = new PartialViewResult
         {
             ViewName = vr.ViewName, TempData = vr.TempData, ViewData = vr.ViewData
         };
         filterContext.Result = pv;
     }
 }
 public ActionResult AddTab(string containerId)
 {
     var result = new PartialViewResult
     {
         ViewName = "Tab",
         ContainerId = containerId,                                
         RenderMode = RenderMode.AddTo
     };
     
     this.GetCmp<TabPanel>(containerId).SetLastTabAsActive();
     
     return result;
 }
        public void TestListInvoiceDetailsForInvoice()
        {
            InvoiceDB db = new InvoiceDB();
            Invoice   i  = db.Invoices.First();

            ((IObjectContextAdapter)db).ObjectContext.Detach(i); //http://stackoverflow.com/questions/4168073/entity-framework-code-first-no-detach-method-on-dbcontext
            Assert.NotNull(i);

            InvoiceDetailsController idc = new InvoiceDetailsController();

            System.Web.Mvc.PartialViewResult result = idc.IndexByInvoice(i.InvoiceID);

            Assert.IsInstanceOf(typeof(List <InvoiceDetails>), result.ViewData.Model);
        }
Esempio n. 26
0
        public override bool TryGetMember(GetMemberBinder binder, out object result)
        {
            string[] parts = binder.Name.Split('_');

            string viewname = parts[0];

            if (parts.Length > 1)
                viewname = viewname + parts[1];
            else
                viewname = "_" + viewname ;

            PartialViewResult vr = new PartialViewResult();

            vr.ViewName = @"~/Views/Shared/" + viewname + ".cshtml";

            result = vr;

            return true;
        }
        public void ReplaceContentsOfElementsWithPartialViewResultContent()
        {
            var partialViewResult = new PartialViewResult();
              var selector = "#selector";

              var result = Taconite.ReplaceContentsOf(selector).WithContent(partialViewResult);

              result.Commands.Should().HaveCount(1);
              var command = result.Commands.Single();
              command.As<ElementCommand>()
            .Should().NotBeNull()
            .ShouldHave().SharedProperties().EqualTo(new
              {
            Command = "replaceContent",
            Html = (string)null,
            Partial = partialViewResult,
            Selector = selector
              });
        }
        public void PrependPartialViewResultContentToElement()
        {
            var partialViewResult = new PartialViewResult();
              var selector = "#selector";

              var result = Taconite.PrependContent(partialViewResult).To(selector);

              result.Commands.Should().HaveCount(1);
              var command = result.Commands.Single();
              command.As<ElementCommand>()
            .Should().NotBeNull()
            .ShouldHave().SharedProperties().EqualTo(new
              {
            Command = "prepend",
            Html = (string) null,
            Partial = partialViewResult,
            Selector = selector
              });
        }
        public virtual ActionResult CreateResult(ControllerContext controllerContext, ActionResult currentResult)
        {
            var viewResult = currentResult as ViewResult;

            if (viewResult == null)
            {
                return null;
            }
   
            var partialViewResult = new PartialViewResult
            {
                ViewData = viewResult.ViewData,
                TempData = viewResult.TempData,
                ViewName = GetPartialViewName(viewResult, controllerContext),
                ViewEngineCollection = viewResult.ViewEngineCollection,
            };

            return partialViewResult;
        }
        public void ExecutePluginWithPartialViewResultContent()
        {
            var plugin = "plugin";
              var selector = "#selector";
              var partialViewResult = new PartialViewResult();

              var result = Taconite.ExecutePlugin(plugin).For(selector).WithContent(partialViewResult);

              result.Commands.Should().HaveCount(1);
              var command = result.Commands.Single();
              command.As<ElementCommand>()
            .Should().NotBeNull()
            .ShouldHave().SharedProperties().EqualTo(new
              {
            Command = plugin,
            Html = (string)null,
            Selector = selector,
            PartialViewResult = partialViewResult
              });
        }
 public PartialViewResult GetResultNew(String PropertyID, String ProjectID)
 {
     String PropertyType = manager.GetPropertyTypePerID(PropertyID);
     Guid ProjID = Guid.Parse(ProjectID);
     Guid PropID = Guid.Parse(PropertyID);
     switch (PropertyType)
     {
         case "Bool":
             {
                 bool res = bool.Parse((new Repository()).PropertiesOfProjects.Where(q => q.PropertyID == PropID && q.ProjectID == ProjID).Select(q => q.PropertyValue).Single());
                 return PartialView("EditBool", new MyBool { a=res, test="testing"});
             }
         default:
             {
                 var results = (new Repository()).PropertiesOfProjects.Where(q => q.PropertyID == PropID && q.ProjectID == ProjID).Select(q => q.PropertyValue).ToList<String>();
                 PartialViewResult a = new PartialViewResult();
                 return PartialView("Editfields", results);
             }
     }
     return new PartialViewResult();
 }
Esempio n. 32
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            string url = filterContext.HttpContext.Request.Url.PathAndQuery;

            if (filterContext.HttpContext.Cache[this.CacheKey] != null)
            {
                filterContext.Result = (ActionResult)filterContext.HttpContext.Cache[this.CacheKey];
            }
            if (filterContext.HttpContext.Request.Url.PathAndQuery.Contains('?') && string.IsNullOrEmpty(filterContext.HttpContext.Request.Url.PathAndQuery.Split('?').LastOrDefault()))
            {
                var shot             = filterContext.ActionParameters["data"] as MortgageCalculator.Web.Models.Shorting;
                var res              = ((System.Web.Mvc.PartialViewResult)(filterContext.Result)).Model as IEnumerable <MortgageCalculator.Web.Models.Mortgage>;
                PartialViewResult vr = new System.Web.Mvc.PartialViewResult
                {
                    ViewName = "~/Views/Shared/_ActiveMortgagePartial.cshtml",
                    ViewData = new ViewDataDictionary(filterContext.Controller.ViewData)
                    {
                        Model = new MortgageCalculator.Web.Models.ServiceCom("").ShortData(shot, res)
                    }
                };
                filterContext.Result = vr as ActionResult;
            }
            base.OnActionExecuting(filterContext);
        }
Esempio n. 33
0
 ///
 public static TaconiteMvc.Syntax.IInsertCommandBeforeOrAfterTargetSyntax InsertContent(System.Web.Mvc.PartialViewResult partialViewResult)
 {
     return((new TaconiteResult()).InsertContent(partialViewResult));
 }
Esempio n. 34
0
 /// <summary>
 /// Appends the content from a <see cref="PartialViewResult"/> to the elements
 /// matching a jQuery selector.
 /// </summary>
 public static TaconiteMvc.Syntax.IAppendCommandToTargetSyntax AppendContent(System.Web.Mvc.PartialViewResult partialViewResult)
 {
     return((new TaconiteResult()).AppendContent(partialViewResult));
 }