Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [TableName("Categories")]
- [PrimaryKey("Id", autoIncrement = true)]
- public class Category : BaseModel
- {
- public int Id { get; set; }
- public string Name { get; set; }
- public List<Category> lstCategory;
- public Category()
- {
- lstCategory = new List<Category>();
- }
- }
- @using SampleLogic
- @using SampleLogic.Models
- @inherits UmbracoTemplatePage
- @{
- Layout = "umbLayout.cshtml";
- var repo = new CategoryRepository();
- }
- <div id="main-wrapper">
- <div id="main" class="container">
- <div class="row">
- <div class="9u skel-cell-mainContent">
- <div class="content content-left">
- @*@Umbraco.RenderMacro("facebookConnect", new {RedirectUrl="2105", HideLoginBox="0"})*@
- @*@Html.Partial("AddCategory" , new Category())*@
- @Html.Action("AddCategory", "SampleSurface")
- @foreach (var category in repo.GetAll())
- {
- <div class="row-fluid">
- <div class="span12">
- <p>@category.Name
- @Html.ActionLink("Edit", "Sample", "Sample", new { id = @category.Id }, null) <a href="?id=@category.Id">Edit</a></p>
- <p>.........................</p>
- </div>
- </div>
- }
- <!-- Content -->
- </div>
- </div>
- </div>
- </div>
- </div>
- using SampleLogic.Models;
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using Umbraco.Core.Models;
- using Umbraco.Web;
- using Umbraco.Web.Models;
- using Umbraco.Web.Mvc;
- namespace SampleLogic.Controllers
- {
- public class SampleController : RenderMvcController
- {
- public ActionResult Sample(int id = 0)
- {
- Category model = new Category();
- var repo = new CategoryRepository();
- if (Request.QueryString["id"] != null)
- {
- model.Name = repo.GetCategoryById(Convert.ToInt32(Request.QueryString["id"])).Name;
- }
- model.lstCategory = repo.GetAll();
- return CurrentTemplate(model);
- }
- }
- }
- using SampleLogic.Models;
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using Umbraco.Core.Models;
- using Umbraco.Web;
- using Umbraco.Web.Mvc;
- namespace SampleLogic.Controllers
- {
- public class SampleSurfaceController : SurfaceController
- {
- [HttpPost]
- public ActionResult Sample(Category model)
- {
- var repo = new CategoryRepository();
- if (model.Id > 0)
- {
- repo.Update(model);
- }
- else
- {
- repo.Insert(model);
- }
- model.Name = string.Empty;
- return CurrentUmbracoPage();
- }
- [ChildActionOnly]
- public ActionResult AddCategory(Category model)
- {
- if (Request.QueryString["id"] != null)
- {
- var repo = new CategoryRepository();
- model.Name = repo.GetCategoryById(Convert.ToInt32(Request.QueryString["id"])).Name;
- }
- //TODO: do some searching (perhaps using Examine)
- //using the information contained in the custom class QueryParameters
- //return the SearchResults to the view
- return PartialView("AddCategory", model);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement