我被要求修复一个具有多个元素的单一布局的MVC解决方案。它依赖于HTML模板Ublod - Responsive Admin Dashboard Template。 我所拥有的是以前不同的开发人员在没有协作的情况下独自工作的结果,现在我应该解决一些问题,但是我束之高阁,无法重写所有内容。 我遇到的问题之一是,在共享的 _Layout 中验证了身份验证,并且PartialView中有一个动态的侧菜单(基于db中的配置文件)。布局还具有一个顶部栏,该栏在配置文件上有所不同。 我要做的第一件事是将sidemenu和topbar放在主_Layout中,只是使身份验证和配置文件只运行一次,而不是运行三次。 主页与其他所有页面均不同,并且当前不依赖于控制器,其他所有视图均基于模板中相同的“ page-starte.html”。 每当我触发操作时,都会重新加载整个页面,并且侧菜单会失去焦点。 我试图遍历Ajax并仅更新包含内容的div,但是我缺少一些东西。 我已经尝试过部分和PartialViews,但是我一定做错了。 我只需要更新内容,而无需重新加载整个页面。 这是_Layout:
@{
string cdnHost = System.Configuration.ConfigurationManager.AppSettings["web:cdnHost"];
var profile = FIRMS_App.Context.UserContext.GetLoggedUser();
var conteggioAttivitaUtenteNormale = profile.UtenteAttivita.Where(a => a.IdUtenteA == profile.Id && a.flagLetto == false).Select<FIRMS_App.UtenteAttivita, FIRMS_App.Attivita>(x => x.Attivita).Where(x => !x.Task).Count();
var conteggioAttivitaUtenteAdmin = profile.UtenteAttivita.Where(a => a.flagLetto == false).Select<FIRMS_App.UtenteAttivita, FIRMS_App.Attivita>(x => x.Attivita).Where(x => !x.Task && x.IdAzienda == profile.IdAzienda).Count();
var conteggioTaskUtenteNormale = profile.UtenteAttivita.Where(a => a.IdUtenteA == profile.Id && a.flagLetto == false && a.idStatoAttivita == 2).Count();
var conteggioTaskUtenteAdmin = profile.UtenteAttivita.Where(a => a.flagLetto == false && a.idStatoAttivita == 2 && a.Attivita.IdAzienda == profile.IdAzienda).Count();
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="A fully featured admin theme which can be used to build CRM, CMS, etc.">
<meta name="author" content="Coderthemes">
<link rel="shortcut icon" href="@Html.Raw(cdnHost)/assets/images/favicon.ico">
<!-- Plugin Css-->
<title>Firms App - @ViewBag.Title</title>
@* @Html.Partial("/firms-web/Views/Shared/_ScriptView.cshtml")*@
<script src="@Html.Raw(cdnHost)/assets/js/jquery.min.js"></script>
<script src="@Html.Raw(cdnHost)/assets/js/popper.min.js"></script>
<script src="@Html.Raw(cdnHost)/assets/js/bootstrap.min.js"></script>
<link href="@Html.Raw(cdnHost)/assets/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="@Html.Raw(cdnHost)/assets/plugins/bootstrap-table/css/bootstrap-table.min.css" rel="stylesheet" type="text/css" />
<script src="@Html.Raw(cdnHost)/Scripts/Main.js"></script>
<link rel="stylesheet" href="@Html.Raw(cdnHost)/assets/plugins/magnific-popup/css/magnific-popup.css" />
<link rel="stylesheet" href="@Html.Raw(cdnHost)/assets/plugins/jquery-datatables-editable/dataTables.bootstrap4.min.css" />
<style>
/*multi-select.css*/
.ms-container {
background: /*transparent*/ url('/assets/plugins/multiselect/img/switch.png') no-repeat 50% 50%;
width: 100%;
}
.label {
height: 35px;
font-size: small;
font-weight: normal;
vertical-align: middle;
line-height: 35px;
padding-top: 0;
padding-bottom: 0;
}
</style>
@if (TempData["Result"] == "_OK")
{
if (TempData["View"] == "") { TempData["View"] = "Lista"; }
<script type="text/javascript">
window.onload = function () {
$(document).ready(function () {
swal({
title: "<i class='i icon-like'></i>", text: "Operazione avvenuta con successo", type: "success"
})
.then(function () {
window.location.href = TempData["View"];//"Lista";
});
});
};
</script>
}
@if (TempData["Result"] == "_KO")
{
<script type="text/javascript">
window.onload = function () {
$(document).ready(function () {
swal({
title: "<i class='i icon-dislike'></i><br>Operazione fallita", text: "@TempData["Message"]", type: "error"
})
.then(function () {
// window.location.href = "New";
});
});
};
</script>
}
<script>
window.onload = function () {
$(document).ready(function () {
MainJS.init();
});
};
</script>
</head>
<body class="fixed-left">
<!-- Begin page -->
<div id="wrapper">
<!-- Top Bar Start -->
<div class="topbar">
<!-- LOGO -->
<div class="topbar-left">
<div class="text-center">
<!-- <a href="index.html" class="logo"><i class="icon-magnet icon-c-logo"></i><span>Ub<i class="md md-album"></i>ld</span></a> -->
<!-- Image Logo here -->
<a href="/Home/Index" class="logo">
<!--<i class="icon-c-logo"> <img src="@Html.Raw(cdnHost)/assets/images/logo_sm.png" height="42"/> </i>-->
<!--<span><img src="@Html.Raw(cdnHost)/assets/images/logo_light.png" height="20"/></span>-->
<span>
<img src="@Html.Raw(cdnHost)/assets/images/savone_logo_160x35.png" height="35" /></span>
</a>
</div>
</div>
<!-- Button mobile view to collapse sidebar menu -->
<nav class="navbar-custom">
<ul class="list-inline float-right mb-0">
<li class="list-inline-item notification-list">
<a class="nav-link waves-light waves-effect" href="#" id="btn-fullscreen">
<i class="dripicons-expand noti-icon"></i>
</a>
</li>
@* --- Redirect to Lista Task --- Start --- *@
<li class="list-inline-item notification-list">
<a class="nav-link right-bar-toggle waves-light waves-effect" href="@Url.Action("Lista", "Task")">
<i class="dripicons-bell noti-icon"></i>
@if (profile.SystemAdmin == false)
{
<span class="badge badge-pink noti-icon-badge">@conteggioAttivitaUtenteNormale</span>}
else
{<span class="badge badge-pink noti-icon-badge">@conteggioAttivitaUtenteAdmin</span>}
</a>
</li>
@* --- Redirect to Lista Task --- End --- *@
@* --- Redirect to Lista Messaggi --- Start --- *@
<li class="list-inline-item notification-list">
<a class="nav-link right-bar-toggle waves-light waves-effect" href="@Url.Action("Lista", "Messaggi")">
@if (profile.SystemAdmin == true)
{
<i class="dripicons-message noti-icon">@conteggioTaskUtenteAdmin</i>
}
@if (profile.SystemAdmin == false)
{
<i class="dripicons-message noti-icon">@conteggioTaskUtenteNormale</i>
}
</a>
</li>
@* --- Redirect to Lista Messaggi --- End --- *@
<li class="list-inline-item dropdown notification-list">
<a class="nav-link dropdown-toggle waves-effect waves-light nav-user" data-toggle="dropdown" href="#" role="button"
aria-haspopup="false" aria-expanded="false">
<img src="@profile.Avatar" alt="" class="thumb-md rounded-circle">>
</a>
<div class="dropdown-menu dropdown-menu-right profile-dropdown " aria-labelledby="Preview">
<!-- item-->
<div class="dropdown-item noti-title">
<h5 class="text-overflow"><small>@Html.Raw(profile.Nome + " " + profile.Cognome)</small> </h5>
</div>
@*@if (profile.SystemAdmin == true)
{
<!-- item-->
<a href="javascript:void(0);" class="dropdown-item notify-item">
<i class="md md-lock-open"></i> <span>Seleziona Azienda</span>
</a>
}*@
<!-- item-->
<a href="@Url.Action("Logout", "Account")" class="dropdown-item notify-item">
<i class="md md-settings-power"></i><span>Logout</span>
</a>
</div>
</li>
</ul>
<ul class="list-inline menu-left mb-0">
<li class="float-left">
<button class="button-menu-mobile open-left waves-light waves-effect">
<i class="dripicons-menu"></i>
</button>
</li>
<li class="hide-phone app-search">
<!-- <form role="search" class="">
<input type="text" placeholder="Search..." class="form-control">
<a href=""><i class="fa fa-search"></i></a>
</form>-->
</li>
</ul>
</nav>
</div>
<!-- Top Bar End -->
<!-- ========== Left Sidebar Start ========== -->
<div class="left side-menu">
<div class="sidebar-inner slimscrollleft">
<div class="user-details">
<div class="pull-left">
<img src="@Html.Raw(profile.Avatar)" alt="" class="thumb-md rounded-circle">
</div>
<div class="user-info">
@*@if (profile.Username == "owner@firms.com") {
<div>@Html.Display(nomeAzienda)</div>
}*@
<div class="dropdown">
@if (profile.Username == "owner@firms.com" && profile.IdAzienda != Guid.Parse("00000000-0000-0000-0000-000000000000"))
{
<a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false">@Html.Raw(profile.Nome + " " + profile.Cognome + " dell'azienda " + profile.Aziende.Azienda)<span class="caret"></span></a>}
else
{<a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false">@Html.Raw(profile.Nome + " " + profile.Cognome)<span class="caret"></span></a>}
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="btnGroupDrop1">
@* @if (profile.SystemAdmin == true)
{
<a class="dropdown-item" href="javascript:void(0)"><i class="md md-settings-power"></i> Seleziona Azienda</a>
}*@
@if (profile.Username == "owner@firms.com")
{
<a class="dropdown-item" href="@Url.Action("SceltaAzienda", "CambiaAzienda")"><i class="md md-swap-vert-circle"></i>Cambia Azienda</a>
}
<a class="dropdown-item" href="@Url.Action("Logout", "Account")"><i class="md md-settings-power"></i>Logout</a>
</div>
</div>
</div>
</div>
<!--- Divider -->
<div id="sidebar-menu">
@if (Request.IsAuthenticated && profile.Navigation != null)
{
<ul>
<li class="text-muted menu-title">Navigazione</li>
@{
var main = profile.Navigation.Select(n => n.MenuPadre).Distinct().ToList();
if (profile.IdAzienda == Guid.Parse("00000000-0000-0000-0000-000000000000"))
{
main = main.Where(x => x.ToLower() == "azienda").ToList();
}
else
{
main = main.Where(x => x.ToLower() != "azienda").ToList();
}
if (profile.Id == Guid.Parse("00000000-0000-0000-0000-000000000000"))
{
main = main.Where(x => x.ToLower() != "conversazioni" && x.ToLower() != "task").ToList();
}
for (var i = 0; i < main.Count; i++)
{
var menus = profile.Navigation.Where(n => n.MenuPadre == main[i]).ToList();
var menu = menus.FirstOrDefault();
@Html.Raw("<li class='has_sub'>")
@Html.Raw(" <a href='javascript:void(0);' class='waves-effect'><i class='" + menu.Etichetta + "'></i> <span> " + menu.MenuPadre + " </span> <span class='menu-arrow'></span></a>")
@Html.Raw(" <ul class='list-unstyled'>")
foreach (var m in menus)
{
@Html.Raw(" <li>" + @Html.ActionLink(m.Menu, m.Action, m.Controller) + "</li>") // ori
//@Html.Raw(" <li><a class=\"dropdown-item\" href=\"" + @Url.Action(m.Menu, m.Controller, new {@class="ajaxLink"}) + "\"></a></li>")
}
@Html.Raw(" </ul>")
@Html.Raw("</li>")
}
}
</ul>
}
<div class="clearfix"></div>
</div>
<div class="clearfix"></div>
<div class="clearfix"></div>
</div>
</div>
<!-- Left Sidebar End -->
@Html.Partial("/Views/Shared/_ScriptView.cshtml")
<!-- ============================================================== -->
<!-- Start right Content here -->
<!-- ============================================================== -->
<div class="content-page">
<!-- Start content -->
<div class="content">
<div class="container-fluid">
@RenderBody()
</div>
<!-- container -->
</div>
<!-- content -->
</div>
<!-- ============================================================== -->
<!-- End Right content here -->
<!-- ============================================================== -->
</div>
<!-- END wrapper -->
@* <footer class="footer text-right">
© @DateTime.Now.Year - FIRMS App
</footer>*@
</body>
</html>
@*<script type="text/javascript">
$(function () {
$("a.ajaxLink").click(function (e) {
e.preventDefault(); // stop the default click behavior
$('#pageContent').empty(); // clean the div
$("#pageContent").load($(this).attr("href"));
});
});
</script>*@
@* <script type="text/javascript">
$(function () {
var myLinkHref = $("a.ajaxLink").eq(0).attr("href"); //Load the link's content on document ready
$("#pageContent").load(myLinkHref);
$("a.ajaxLink").click(function (e) {
e.preventDefault();
$("#pageContent").load($(this).attr("href"));
});
});
</script>*@
@*$("#callLogs").on("click", function () {
$.ajax({
url: '@Url.Action("callLogs", "YourControllerName")',
success: function (response) {
$("#container_inner_frame").html(response);
}
error: function () {
alert("error occured");
}
});
});*@
这是一个示例视图:
@model FIRMS_App.Models.DTO.ListaConversazioniView
@{
ViewBag.Title = "Lista";
//string cdnHost = System.Configuration.ConfigurationManager.AppSettings["web:cdnHost"];// ;
string cdnHost = "http://localhost:48129";
}
<div id="wrapper">
<div class="container-fluid">
<!-- Page-Title -->
<div class="row">
<div class="col-sm-12">
<h4 class="page-title">Inbox</h4>
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="#">Admin</a></li>
<li class="breadcrumb-item"><a href="#">Conversazioni</a></li>
<li class="breadcrumb-item active">Lista Conversazioni</li>
</ol>
</div>
</div>
<div class="row">
<!-- Right Sidebar -->
<div class="col-xl-9 col-lg-8">
@using (Html.BeginForm("Conversazioni", "Messaggi", FormMethod.Post, new { id = "form1", name = "form1" }))
{ @Html.HiddenFor(x => x.idAttivita, new { @id = "selectedItemId" });
<div class="card-box p-1 m-t-20">
<div class="panel-body p-0">
<div class="table-responsive">
<table class="table table-hover mails m-0">
<tbody>
@{string nome = "";
}
@if (Model.listaAttivita.Count() > 0)
{
foreach (var item in Model.listaAttivita.OrderBy(x => x.attivita.ModifiedDate).OrderBy(x => x.flagLetto))
{
if (nome != item.attivita.Oggetto)
{
var clazz = "";
if (!item.flagLetto)
{
clazz = "unread";
}
<tr class="@clazz">
<td class="mail-select">
@* <div class="checkbox checkbox-primary m-r-15">
<input id="checkbox1" type="checkbox">
<label for="checkbox1"></label>
</div>*@
<i class="fa fa-star m-r-15 text-muted"></i>
@if (item.flagLetto == false)
{
<i class="fa fa-circle m-l-5 text-info"></i>
}
else
{ <i class="fa fa-circle m-l-5 text-success"></i>}
</td>
<td>
<a href="#" onclick="MainJS.selectForAssocia('@item.attivita.Id', 'form1');" class="email-name">@item.NomeCreatore</a>
</td>
<td class="hidden-xs">
<a href="#" onclick="MainJS.selectForAssocia('@item.attivita.Id', 'form1');" class="email-msg">@item.attivita.Oggetto</a>
</td>
<td class="text-right">@item.attivita.CreatedDate.GetValueOrDefault().ToShortDateString()
</td>
<td class="text-right">@item.attivita.CreatedDate.GetValueOrDefault().ToShortTimeString()
</td>
</tr> nome = item.attivita.Oggetto;
}
}
}
else
{<div class="form-control" style="text-align: center">La cartella Inbox è vuota</div>}
</tbody>
</table>
</div>
</div>
<!-- panel body -->
</div>
}
<!-- panel -->
</div>
<!-- end Col-9 -->
</div>
<!-- End row -->
</div>
<!-- container -->
</div>
<!-- content -->
这是相对控制器的一部分:
[System.Web.Mvc.HttpGet]
public ActionResult Lista()
{
Profile profile = FIRMS_App.Context.UserContext.GetLoggedUser();
List<AttivitaLettura> listaMessaggi = new List<AttivitaLettura>();
if (profile != null)
listaMessaggi = this._attivitaService.GetListaAttivitaPerLettura(profile.IdAzienda).Where(x => !x.attivita.Task).ToList();
ListaConversazioniView Model = new ListaConversazioniView();
Model.listaAttivita = listaMessaggi;
if (Request.IsAjaxRequest())
return PartialView("pView", Model);
else
return View(Model);
}
ASP.Net是4.5版
感谢您的帮助。
答案 0 :(得分:0)
论坛中没有其他人的帮助,但是最后,我以一种不太优雅的方式解决了这个问题。因为我知道的是.Net和C#,所以即使我总是被告知视图和布局应使用尽可能少的代码,我还是直接在Layout中进行管理。 我从重建页面 Request.Path 的URL中恢复了调用视图,并使用开关/大小写将其映射到源db。这是最终结果:
@{
string cdnHost = System.Configuration.ConfigurationManager.AppSettings["web:cdnHost"];
var profile = FIRMS_App.Context.UserContext.GetLoggedUser();
var conteggioAttivitaUtenteNormale = profile.UtenteAttivita.Where(a => a.IdUtenteA == profile.Id && a.flagLetto == false).Select<FIRMS_App.UtenteAttivita, FIRMS_App.Attivita>(x => x.Attivita).Where(x => !x.Task).Count();
var conteggioAttivitaUtenteAdmin = profile.UtenteAttivita.Where(a => a.flagLetto == false).Select<FIRMS_App.UtenteAttivita, FIRMS_App.Attivita>(x => x.Attivita).Where(x => !x.Task && x.IdAzienda == profile.IdAzienda).Count();
var conteggioTaskUtenteNormale = profile.UtenteAttivita.Where(a => a.IdUtenteA == profile.Id && a.flagLetto == false && a.idStatoAttivita == 2).Count();
var conteggioTaskUtenteAdmin = profile.UtenteAttivita.Where(a => a.flagLetto == false && a.idStatoAttivita == 2 && a.Attivita.IdAzienda == profile.IdAzienda).Count();
}
<!DOCTYPE html>
@*<html>*@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="A fully featured admin theme which can be used to build CRM, CMS, etc.">
<meta name="author" content="Coderthemes">
<link rel="shortcut icon" href="@Html.Raw(cdnHost)/assets/images/favicon.ico">
<!-- Plugin Css-->
<title>Firms App - @ViewBag.Title</title>
@* @Html.Partial("/firms-web/Views/Shared/_ScriptView.cshtml")*@
<script src="@Html.Raw(cdnHost)/assets/js/jquery.min.js"></script>
<script src="@Html.Raw(cdnHost)/assets/js/popper.min.js"></script>
<script src="@Html.Raw(cdnHost)/assets/js/bootstrap.min.js"></script>
<link href="@Html.Raw(cdnHost)/assets/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="@Html.Raw(cdnHost)/assets/plugins/bootstrap-table/css/bootstrap-table.min.css" rel="stylesheet" type="text/css" />
<script src="@Html.Raw(cdnHost)/Scripts/Main.js"></script>
<link rel="stylesheet" href="@Html.Raw(cdnHost)/assets/plugins/magnific-popup/css/magnific-popup.css" />
<link rel="stylesheet" href="@Html.Raw(cdnHost)/assets/plugins/jquery-datatables-editable/dataTables.bootstrap4.min.css" />
<style>
/*multi-select.css*/
.ms-container {
background: /*transparent*/ url('/assets/plugins/multiselect/img/switch.png') no-repeat 50% 50%;
width: 100%;
}
.label {
height: 35px;
font-size: small;
font-weight: normal;
vertical-align: middle;
line-height: 35px;
padding-top: 0;
padding-bottom: 0;
}
</style>
@if (TempData["Result"] == "_OK")
{
if (TempData["View"] == "") { TempData["View"] = "Lista"; }
<script type="text/javascript">
window.onload = function () {
$(document).ready(function () {
swal({
title: "<i class='i icon-like'></i>", text: "Operazione avvenuta con successo", type: "success"
})
.then(function () {
window.location.href = TempData["View"];//"Lista";
});
});
};
</script>
}
@if (TempData["Result"] == "_KO")
{
<script type="text/javascript">
window.onload = function () {
$(document).ready(function () {
swal({
title: "<i class='i icon-dislike'></i><br>Operazione fallita", text: "@TempData["Message"]", type: "error"
})
.then(function () {
// window.location.href = "New";
});
});
};
</script>
}
<script>
window.onload = function () {
$(document).ready(function () {
MainJS.init();
});
};
</script>
</head>
<body class="fixed-left">
<!-- Begin page -->
<div id="wrapper">
<!-- Top Bar Start -->
<div class="topbar">
<!-- LOGO -->
<div class="topbar-left">
<div class="text-center">
<!-- <a href="index.html" class="logo"><i class="icon-magnet icon-c-logo"></i><span>Ub<i class="md md-album"></i>ld</span></a> -->
<!-- Image Logo here -->
<a href="/Home/Index" class="logo">
<!--<i class="icon-c-logo"> <img src="@Html.Raw(cdnHost)/assets/images/logo_sm.png" height="42"/> </i>-->
<!--<span><img src="@Html.Raw(cdnHost)/assets/images/logo_light.png" height="20"/></span>-->
<span>
<img src="@Html.Raw(cdnHost)/assets/images/savone_logo_160x35.png" height="35" /></span>
</a>
</div>
</div>
<!-- Button mobile view to collapse sidebar menu -->
<nav class="navbar-custom">
<ul class="list-inline float-right mb-0">
<li class="list-inline-item notification-list">
<a class="nav-link waves-light waves-effect" href="#" id="btn-fullscreen">
<i class="dripicons-expand noti-icon"></i>
</a>
</li>
@* --- Redirect to Lista Task --- Start --- *@
<li class="list-inline-item notification-list">
<a class="nav-link right-bar-toggle waves-light waves-effect" href="@Url.Action("Lista", "Task")">
<i class="dripicons-bell noti-icon"></i>
@if (profile.SystemAdmin == false)
{
<span class="badge badge-pink noti-icon-badge">@conteggioAttivitaUtenteNormale</span>}
else
{<span class="badge badge-pink noti-icon-badge">@conteggioAttivitaUtenteAdmin</span>}
</a>
</li>
@* --- Redirect to Lista Task --- End --- *@
@* --- Redirect to Lista Messaggi --- Start --- *@
<li class="list-inline-item notification-list">
<a class="nav-link right-bar-toggle waves-light waves-effect" href="@Url.Action("Lista", "Messaggi")">
@if (profile.SystemAdmin == true)
{
<i class="dripicons-message noti-icon">@conteggioTaskUtenteAdmin</i>
}
@if (profile.SystemAdmin == false)
{
<i class="dripicons-message noti-icon">@conteggioTaskUtenteNormale</i>
}
</a>
</li>
@* --- Redirect to Lista Messaggi --- End --- *@
<li class="list-inline-item dropdown notification-list">
<a class="nav-link dropdown-toggle waves-effect waves-light nav-user" data-toggle="dropdown" href="#" role="button"
aria-haspopup="false" aria-expanded="false">
<img src="@profile.Avatar" alt="" class="thumb-md rounded-circle">>
</a>
<div class="dropdown-menu dropdown-menu-right profile-dropdown " aria-labelledby="Preview">
<!-- item-->
<div class="dropdown-item noti-title">
<h5 class="text-overflow"><small>@Html.Raw(profile.Nome + " " + profile.Cognome)</small> </h5>
</div>
@*@if (profile.SystemAdmin == true)
{
<!-- item-->
<a href="javascript:void(0);" class="dropdown-item notify-item">
<i class="md md-lock-open"></i> <span>Seleziona Azienda</span>
</a>
}*@
<!-- item-->
<a href="@Url.Action("Logout", "Account")" class="dropdown-item notify-item">
<i class="md md-settings-power"></i><span>Logout</span>
</a>
</div>
</li>
</ul>
<ul class="list-inline menu-left mb-0">
<li class="float-left">
<button class="button-menu-mobile open-left waves-light waves-effect">
<i class="dripicons-menu"></i>
</button>
</li>
<li class="hide-phone app-search">
<!-- <form role="search" class="">
<input type="text" placeholder="Search..." class="form-control">
<a href=""><i class="fa fa-search"></i></a>
</form>-->
</li>
</ul>
</nav>
</div>
<!-- Top Bar End -->
<!-- ========== Left Sidebar Start ========== -->
<div class="left side-menu">
<div class="sidebar-inner slimscrollleft">
<div class="user-details">
<div class="pull-left">
<img src="@Html.Raw(profile.Avatar)" alt="" class="thumb-md rounded-circle">
</div>
<div class="user-info">
@*@if (profile.Username == "owner@firms.com") {
<div>@Html.Display(nomeAzienda)</div>
}*@
<div class="dropdown">
@if (profile.Username == "owner@firms.com" && profile.IdAzienda != Guid.Parse("00000000-0000-0000-0000-000000000000"))
{
<a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false">@Html.Raw(profile.Nome + " " + profile.Cognome + " dell'azienda " + profile.Aziende.Azienda)<span class="caret"></span></a>}
else
{<a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false">@Html.Raw(profile.Nome + " " + profile.Cognome)<span class="caret"></span></a>}
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="btnGroupDrop1">
@* @if (profile.SystemAdmin == true)
{
<a class="dropdown-item" href="javascript:void(0)"><i class="md md-settings-power"></i> Seleziona Azienda</a>
}*@
@if (profile.Username == "owner@firms.com")
{
<a class="dropdown-item" href="@Url.Action("SceltaAzienda", "CambiaAzienda")"><i class="md md-swap-vert-circle"></i>Cambia Azienda</a>
}
<a class="dropdown-item" href="@Url.Action("Logout", "Account")"><i class="md md-settings-power"></i>Logout</a>
</div>
</div>
</div>
</div>
<!--- Divider -->
<div id="sidebar-menu">
@if (Request.IsAuthenticated && profile.Navigation != null)
{
// set navigation menu to launcher
string[] navcfg = (Request.Path).Split(new char[] { '/' });
string padre = (navcfg[1] == "Messaggi" ? "Conversazioni" : navcfg[1]);
string mnu = navcfg[2];
switch (Request.Path)
{
case "/Aziende/Lista":
mnu = "Lista Aziende";
break;
case "/Aziende/New":
mnu = "Nuova Azienda";
break;
case "/Reparti/Lista":
mnu = "Lista Reparti";
break;
case "/Reparti/New":
mnu = "Nuovo Reparto";
break;
case "/Reparti/Associa":
mnu = "Associa Reparto";
break;
case "/Profili/Lista":
mnu = "Lista Profili";
break;
case "/Profili/New":
mnu = "Nuovo Profilo";
break;
case "/Utenti/Lista":
mnu = "Lista Utenti";
break;
case "/Utenti/New":
mnu = "Nuovo Utente";
break;
case "/Dispositivi/Lista":
mnu = "Lista Dispositivi";
break;
case "/Dispositivi/New":
mnu = "Nuovo Dispositivo";
break;
case "/Dispositivi/Tipi":
mnu = "Tipi Dispositivo";
break;
case "/Dispositivi/Associa":
mnu = "Associa Dispositivo";
break;
case "/Task/Lista":
mnu = "Lista Task";
break;
case "/Task/New":
mnu = "Nuovo Task";
break;
case "/Messaggi/Lista":
mnu = "Lista Messaggi";
break;
case "/Messaggi/New":
mnu = "Nuovo Messaggio";
break;
case "/Profili/Associa":
mnu = "Associa Menu";
break;
case "/Utenti/Associa":
mnu = "Associa Profilo";
break;
case "/Dispositivi/TipoNew":
mnu = "Nuovo Tipo Dispositivo";
break;
case "/Dispositivi/Riepilogo":
mnu = "Riepilogo";
break;
case "/Features/Features":
mnu = "Features";
break;
case "/Servizi/Servizi":
mnu = "Chiama servizi";
break;
case "/Log/Log":
mnu = "Lista log";
break;
default:
mnu = "Index";
break;
}
<ul>
<li class="text-muted menu-title">Navigazione</li>
@{
var main = profile.Navigation.Select(n => n.MenuPadre).Distinct().ToList();
if (profile.IdAzienda == Guid.Parse("00000000-0000-0000-0000-000000000000"))
{
main = main.Where(x => x.ToLower() == "azienda").ToList();
}
else
{
main = main.Where(x => x.ToLower() != "azienda").ToList();
}
if (profile.Id == Guid.Parse("00000000-0000-0000-0000-000000000000"))
{
main = main.Where(x => x.ToLower() != "conversazioni" && x.ToLower() != "task").ToList();
}
for (var i = 0; i < main.Count; i++)
{
var menus = profile.Navigation.Where(n => n.MenuPadre == main[i]).ToList();
var menu = menus.FirstOrDefault();
@Html.Raw("<li class='has_sub'>")
//@Html.Raw(" <a href='javascript:void(0);' class='waves-effect'><i class='" + menu.Etichetta + "'></i> <span> " + menu.MenuPadre + " </span> <span class='menu-arrow'></span></a>")
//@Html.Raw(" <ul class='list-unstyled'>")
if (menu.MenuPadre == padre.ToUpper())
{
@Html.Raw(" <a href='javascript:void(0);' class='waves-effect subdrop'><i class='" + menu.Etichetta + "'></i> <span> " + menu.MenuPadre + " </span> <span class='menu-arrow'></span></a>")
@Html.Raw(" <ul style=\"display: block\" class='list-unstyled'>")
}
else
{
@Html.Raw(" <a href='javascript:void(0);' class='waves-effect'><i class='" + menu.Etichetta + "'></i> <span> " + menu.MenuPadre + " </span> <span class='menu-arrow'></span></a>")
@Html.Raw(" <ul class='list-unstyled'>")
}
//foreach (var m in menus)
//{
// @Html.Raw(" <li>" + @Html.ActionLink(m.Menu, m.Action, m.Controller) + "</li>") // ori
//}
foreach (var m in menus)
{
if (m.Menu == mnu)
{
@Html.Raw(" <li class = 'active'>" + @Html.ActionLink(m.Menu, m.Action, m.Controller) + "</li>")
}
else
{
@Html.Raw(" <li>" + @Html.ActionLink(m.Menu, m.Action, m.Controller) + "</li>") // ori
}
}
@Html.Raw(" </ul>")
@Html.Raw("</li>")
}
}
</ul>
}
<div class="clearfix"></div>
</div>
<div class="clearfix"></div>
<div class="clearfix"></div>
</div>
</div>
<!-- Left Sidebar End -->
@Html.Partial("/Views/Shared/_ScriptView.cshtml")
<!-- ============================================================== -->
<!-- Start right Content here -->
<!-- ============================================================== -->
<div class="content-page">
<!-- Start content -->
<div class="content">
<div class="container-fluid">
@RenderBody()
</div>
<!-- container -->
</div>
<!-- content -->
</div>
<!-- ============================================================== -->
<!-- End Right content here -->
<!-- ============================================================== -->
</div>
<!-- END wrapper -->
@* <footer class="footer text-right">
© @DateTime.Now.Year - FIRMS App
</footer>*@
</body>
@*</html>*@