Created
October 1, 2013 03:01
-
-
Save cleytonferrari/6773325 to your computer and use it in GitHub Desktop.
Vários dominios para varios temas em um mesmo site
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Web; | |
using System.Web.Mvc; | |
using PagedList; | |
using W7.Camara.Aplicacao; | |
using W7.Camara.UI.Web.Site.ViewModel; | |
namespace W7.Camara.UI.Web.Site.Controllers | |
{ | |
public class AtaController : Controller | |
{ | |
private AtaAplicacao ataAplicacao; | |
public ActionResult Index(int? page) | |
{ | |
ataAplicacao = new AtaAplicacao(); | |
var numeroDaPagina = page ?? 1; | |
var viewModel = new AtaViewModel | |
{ | |
TodasAtas = ataAplicacao.UltimasAtas(Camara.CamaraDados().IdCamara).ToPagedList(numeroDaPagina, 10) | |
}; | |
ViewBag.tema = Camara.CamaraDados().Tema; | |
return View("~/Views/temas/"+ Camara.CamaraDados().Tema +"/Ata/Todasata.cshtml", viewModel); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Web; | |
using W7.Camara.Aplicacao; | |
namespace W7.Camara.UI.Web.Site.Controllers | |
{ | |
public class Camara | |
{ | |
public static Site CamaraDados() | |
{ | |
var camaraAplicacao = new CamaraAplicacao(); | |
var url = HttpContext.Current.Request.Url.Host; | |
url = url.Replace("www.", ""); | |
var camaraAtual = camaraAplicacao.BuscarPorUrl(url); | |
if (camaraAtual == null) | |
{ | |
return new Site(); | |
} | |
var site = new Site | |
{ | |
IdCamara = camaraAtual.Id, | |
Tema = camaraAtual.TemaSite | |
}; | |
return site; | |
} | |
} | |
public class Site | |
{ | |
public string IdCamara { get; set; } | |
public string Tema { get; set; } | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ai tu vai precisar de ter uma estrutura de pastas: | |
Views | |
- Temas | |
- meusite01.com.br | |
- Ata | |
- Index.cshtml | |
- meusite02.com.br | |
- Ata | |
- Index.cshtml | |
Quando as requisições vierem de meusite01 ele entra neste tema! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@using W7.Camara.Dominio | |
@model W7.Camara.UI.Web.Site.ViewModel.AtaViewModel | |
@{ | |
Layout = "~/Views/temas/" + ViewBag.tema + "/Layout/_Layout.cshtml"; | |
var tema = ViewBag.tema; | |
} | |
<div class="envolve conteudo-fnd"> | |
<div class="conteudo noticia-int"> | |
<h2>@Model.AtaCompleta.Nome</h2> | |
<span>@Model.AtaCompleta.Sessao.DataSessao.ToString("dd/MM/yyyy HH:mm") </span> | |
<p style="white-space: pre-line">@Html.Raw(Model.AtaCompleta.Conteudo) </p> | |
@if (Model.AtaCompleta.Anexos != null) | |
{ | |
<h5>Lista de anexos:</h5> | |
<ul> | |
@foreach (Anexo anexo in Model.AtaCompleta.Anexos) | |
{ | |
<li><a href="~/Home/Arquivo?id=@anexo.ArquivoId" target="_blank">@anexo.Descricao</a></li> | |
} | |
</ul> | |
} | |
</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment