code format
This commit is contained in:
@ -21,11 +21,11 @@ namespace Yavsc.Controllers
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
public class HomeController : Controller
|
public class HomeController : Controller
|
||||||
{
|
{
|
||||||
IHostingEnvironment _hosting;
|
IHostingEnvironment _hosting;
|
||||||
|
|
||||||
ApplicationDbContext _dbContext;
|
ApplicationDbContext _dbContext;
|
||||||
|
|
||||||
readonly IHtmlLocalizer _localizer;
|
readonly IHtmlLocalizer _localizer;
|
||||||
public HomeController(IHtmlLocalizer<Startup> localizer, IHostingEnvironment hosting,
|
public HomeController(IHtmlLocalizer<Startup> localizer, IHostingEnvironment hosting,
|
||||||
ApplicationDbContext context, UserManager<ApplicationUser> userManager)
|
ApplicationDbContext context, UserManager<ApplicationUser> userManager)
|
||||||
{
|
{
|
||||||
@ -36,42 +36,45 @@ namespace Yavsc.Controllers
|
|||||||
|
|
||||||
public async Task<IActionResult> Index(string id)
|
public async Task<IActionResult> Index(string id)
|
||||||
{
|
{
|
||||||
ViewBag.IsFromSecureProx = (Request.Headers.ContainsKey(Constants.SshHeaderKey))? Request.Headers[Constants.SshHeaderKey]=="on" : false ;
|
ViewBag.IsFromSecureProx = (Request.Headers.ContainsKey(Constants.SshHeaderKey)) ? Request.Headers[Constants.SshHeaderKey] == "on" : false;
|
||||||
ViewBag.SecureHomeUrl = "https://"+Request.Headers["X-Forwarded-Host"];
|
ViewBag.SecureHomeUrl = "https://" + Request.Headers["X-Forwarded-Host"];
|
||||||
ViewBag.SshHeaderKey = Request.Headers[Constants.SshHeaderKey];
|
ViewBag.SshHeaderKey = Request.Headers[Constants.SshHeaderKey];
|
||||||
var uid = User.GetUserId();
|
var uid = User.GetUserId();
|
||||||
long [] clicked=null;
|
long[] clicked = null;
|
||||||
if (uid==null) {
|
if (uid == null)
|
||||||
|
{
|
||||||
await HttpContext.Session.LoadAsync();
|
await HttpContext.Session.LoadAsync();
|
||||||
var strclicked = HttpContext.Session.GetString("clicked");
|
var strclicked = HttpContext.Session.GetString("clicked");
|
||||||
if (strclicked!=null) clicked = strclicked.Split(':').Select(c=>long.Parse(c)).ToArray();
|
if (strclicked != null) clicked = strclicked.Split(':').Select(c => long.Parse(c)).ToArray();
|
||||||
if (clicked==null) clicked = new long [0];
|
if (clicked == null) clicked = new long[0];
|
||||||
}
|
}
|
||||||
else clicked = _dbContext.DimissClicked.Where(d=>d.UserId == uid).Select(d=>d.NotificationId).ToArray();
|
else clicked = _dbContext.DimissClicked.Where(d => d.UserId == uid).Select(d => d.NotificationId).ToArray();
|
||||||
var notes = _dbContext.Notification.Where(
|
var notes = _dbContext.Notification.Where(
|
||||||
n=> !clicked.Contains(n.Id)
|
n => !clicked.Contains(n.Id)
|
||||||
);
|
);
|
||||||
this.Notify(notes);
|
this.Notify(notes);
|
||||||
ViewData["HaircutCommandCount"] = _dbContext.HairCutQueries.Where(
|
|
||||||
q=>q.ClientId == uid && q.Status < QueryStatus.Failed
|
|
||||||
).Count();
|
|
||||||
var toShow = _dbContext.Activities
|
|
||||||
.Include(a=>a.Forms)
|
|
||||||
.Include(a=>a.Parent)
|
|
||||||
.Include(a=>a.Children)
|
|
||||||
.Where(a=>!a.Hidden)
|
|
||||||
.Where(a=>a.ParentCode==id)
|
|
||||||
.OrderByDescending(a=>a.Rate).ToList();
|
|
||||||
|
|
||||||
foreach (var a in toShow) {
|
ViewData["HaircutCommandCount"] = _dbContext.HairCutQueries.Where(
|
||||||
a.Children=a.Children.Where(c => !c.Hidden).ToList();
|
q => q.ClientId == uid && q.Status < QueryStatus.Failed
|
||||||
|
).Count();
|
||||||
|
var toShow = _dbContext.Activities
|
||||||
|
.Include(a => a.Forms)
|
||||||
|
.Include(a => a.Parent)
|
||||||
|
.Include(a => a.Children)
|
||||||
|
.Where(a => !a.Hidden)
|
||||||
|
.Where(a => a.ParentCode == id)
|
||||||
|
.OrderByDescending(a => a.Rate).ToList();
|
||||||
|
|
||||||
|
foreach (var a in toShow)
|
||||||
|
{
|
||||||
|
a.Children = a.Children.Where(c => !c.Hidden).ToList();
|
||||||
}
|
}
|
||||||
return View(toShow);
|
return View(toShow);
|
||||||
}
|
}
|
||||||
public async Task<IActionResult> About()
|
public async Task<IActionResult> About()
|
||||||
{
|
{
|
||||||
FileInfo fi = new FileInfo("wwwroot/version");
|
FileInfo fi = new FileInfo("wwwroot/version");
|
||||||
return View("About",fi.Exists ? _localizer["Version logicielle: "] + await fi.OpenText().ReadToEndAsync() : _localizer["Aucune information sur la version logicielle n'est publiée."]);
|
return View("About", fi.Exists ? _localizer["Version logicielle: "] + await fi.OpenText().ReadToEndAsync() : _localizer["Aucune information sur la version logicielle n'est publiée."]);
|
||||||
}
|
}
|
||||||
public IActionResult Privacy()
|
public IActionResult Privacy()
|
||||||
{
|
{
|
||||||
@ -89,12 +92,14 @@ namespace Yavsc.Controllers
|
|||||||
|
|
||||||
public ActionResult Chat()
|
public ActionResult Chat()
|
||||||
{
|
{
|
||||||
if (User.Identity.IsAuthenticated) {
|
if (User.Identity.IsAuthenticated)
|
||||||
ViewBag.IsAuthenticated=true;
|
{
|
||||||
|
ViewBag.IsAuthenticated = true;
|
||||||
string uid = User.GetUserId();
|
string uid = User.GetUserId();
|
||||||
ViewBag.Contacts = _dbContext.Contact.Where(c=>c.OwnerId == uid)
|
ViewBag.Contacts = _dbContext.Contact.Where(c => c.OwnerId == uid)
|
||||||
;
|
;
|
||||||
} else ViewBag.IsAuthenticated=false;
|
}
|
||||||
|
else ViewBag.IsAuthenticated = false;
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,24 +112,24 @@ namespace Yavsc.Controllers
|
|||||||
public IActionResult Status(int id)
|
public IActionResult Status(int id)
|
||||||
{
|
{
|
||||||
ViewBag.StatusCode = id;
|
ViewBag.StatusCode = id;
|
||||||
return View("~/Views/Shared/Status.cshtml");
|
return View("~/Views/Shared/Status.cshtml");
|
||||||
}
|
}
|
||||||
public IActionResult Todo()
|
public IActionResult Todo()
|
||||||
{
|
{
|
||||||
User.GetUserId();
|
User.GetUserId();
|
||||||
|
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IActionResult VideoChat()
|
public IActionResult VideoChat()
|
||||||
{
|
{
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IActionResult Audio()
|
public IActionResult Audio()
|
||||||
{
|
{
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user