FIXME SR is private
This commit is contained in:
@ -1,27 +1,20 @@
|
||||
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Identity;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.OptionsModel;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Services;
|
||||
using Yavsc.ViewModels.Account;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Data.Entity;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Yavsc.Abstract.Manage;
|
||||
using Yavsc.Auth;
|
||||
using Yavsc.Helpers;
|
||||
|
||||
public class AccountController : Controller
|
||||
@ -54,11 +47,6 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
_userManager = userManager;
|
||||
_signInManager = signInManager;
|
||||
var emailUserTokenProvider = new UserTokenProvider();
|
||||
_userManager.RegisterTokenProvider("EmailConfirmation", emailUserTokenProvider);
|
||||
_userManager.RegisterTokenProvider("ResetPassword", emailUserTokenProvider);
|
||||
// _userManager.RegisterTokenProvider("SMS",new UserTokenProvider());
|
||||
// _userManager.RegisterTokenProvider("Phone", new UserTokenProvider());
|
||||
_emailSender = emailSender;
|
||||
_siteSettings = siteSettings.Value;
|
||||
_twilioSettings = twilioSettings.Value;
|
||||
@ -86,7 +74,7 @@ namespace Yavsc.Controllers
|
||||
var toShow = users.Skip(shown).Take(pageLen);
|
||||
|
||||
ViewBag.page = pageNum;
|
||||
ViewBag.hasNext = await users.CountAsync() > (toShow.Count() + shown);
|
||||
ViewBag.hasNext = users.Count() > (toShow.Count() + shown);
|
||||
ViewBag.nextpage = pageNum+1;
|
||||
ViewBag.pageLen = pageLen;
|
||||
// ApplicationUser user;
|
||||
@ -122,7 +110,8 @@ namespace Yavsc.Controllers
|
||||
[AllowAnonymous]
|
||||
public ActionResult AccessDenied(string requestUrl = null)
|
||||
{
|
||||
ViewBag.UserIsSignedIn = User.IsSignedIn();
|
||||
ViewBag.UserIsSignedIn = User.Identity.IsAuthenticated;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(requestUrl))
|
||||
if (string.IsNullOrWhiteSpace(Request.Headers["Referer"]))
|
||||
requestUrl = "/";
|
||||
@ -198,13 +187,7 @@ namespace Yavsc.Controllers
|
||||
if (string.IsNullOrEmpty(model.Provider))
|
||||
{
|
||||
_logger.LogWarning("Provider not specified");
|
||||
return HttpBadRequest();
|
||||
}
|
||||
|
||||
if (!_signInManager.GetExternalAuthenticationSchemes().Any(x => x.AuthenticationScheme == model.Provider))
|
||||
{
|
||||
_logger.LogWarning($"Provider not found : {model.Provider}");
|
||||
return HttpBadRequest();
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
// Instruct the middleware corresponding to the requested external identity
|
||||
@ -217,7 +200,7 @@ namespace Yavsc.Controllers
|
||||
if (string.IsNullOrEmpty(model.ReturnUrl))
|
||||
{
|
||||
_logger.LogWarning("ReturnUrl not specified");
|
||||
return HttpBadRequest();
|
||||
return BadRequest();
|
||||
}
|
||||
// Note: this still is not the redirect uri given to the third party provider, at building the challenge.
|
||||
var redirectUrl = Url.Action("ExternalLoginCallback", "Account", new { model.ReturnUrl }, protocol:"https", host: Startup.Authority);
|
||||
@ -364,7 +347,8 @@ namespace Yavsc.Controllers
|
||||
}
|
||||
|
||||
// Sign in the user with this external login provider if the user already has a login.
|
||||
info.ProviderDisplayName = info.ExternalPrincipal.Claims.First(c => c.Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name")?.Value;
|
||||
throw new NotImplementedException();
|
||||
// info.ProviderDisplayName = info.ExternalPrincipal.Claims.First(c => c.Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name")?.Value;
|
||||
|
||||
var result = await _signInManager.ExternalLoginSignInAsync(info.LoginProvider, info.ProviderKey, isPersistent: false);
|
||||
if (result.Succeeded)
|
||||
@ -392,9 +376,9 @@ namespace Yavsc.Controllers
|
||||
// If the user does not have an account, then ask the user to create an account.
|
||||
ViewData["ReturnUrl"] = returnUrl;
|
||||
ViewData["LoginProvider"] = info.LoginProvider;
|
||||
var email = info.ExternalPrincipal.FindFirstValue(ClaimTypes.Email);
|
||||
var name = info.ExternalPrincipal.FindFirstValue(ClaimTypes.Name);
|
||||
var avatar = info.ExternalPrincipal.FindFirstValue("urn:google:profile");
|
||||
var email = info.AuthenticationProperties.GetParameter<string>(ClaimTypes.Email);
|
||||
var name = info.AuthenticationProperties.GetParameter<string>(ClaimTypes.Name);
|
||||
var avatar = info.AuthenticationProperties.GetParameter<string>("urn:google:profile");
|
||||
/* var phone = info.ExternalPrincipal.FindFirstValue(ClaimTypes.HomePhone);
|
||||
var mobile = info.ExternalPrincipal.FindFirstValue(ClaimTypes.MobilePhone);
|
||||
var postalcode = info.ExternalPrincipal.FindFirstValue(ClaimTypes.PostalCode);
|
||||
@ -403,9 +387,9 @@ namespace Yavsc.Controllers
|
||||
foreach (var claim in info.ExternalPrincipal.Claims)
|
||||
_logger.LogWarning("# {0} Claim: {1} {2}", info.LoginProvider, claim.Type, claim.Value);
|
||||
*/
|
||||
var access_token = info.ExternalPrincipal.FindFirstValue("access_token");
|
||||
var token_type = info.ExternalPrincipal.FindFirstValue("token_type");
|
||||
var expires_in = info.ExternalPrincipal.FindFirstValue("expires_in");
|
||||
var access_token = info.AuthenticationProperties.GetParameter<string>("access_token");
|
||||
var token_type = info.AuthenticationProperties.GetParameter<string>("token_type");
|
||||
var expires_in = info.AuthenticationProperties.GetParameter<string>("expires_in");
|
||||
|
||||
return View("ExternalLoginConfirmation", new ExternalLoginConfirmationViewModel
|
||||
{
|
||||
@ -439,7 +423,8 @@ namespace Yavsc.Controllers
|
||||
var result = await _userManager.CreateAsync(user);
|
||||
if (result.Succeeded)
|
||||
{
|
||||
info.ProviderDisplayName = info.ExternalPrincipal.Claims.First(c => c.Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name")?.Value;
|
||||
throw new NotImplementedException();
|
||||
// info.ProviderDisplayName = info.Claims.First(c => c.Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name")?.Value;
|
||||
|
||||
result = await _userManager.AddLoginAsync(user, info);
|
||||
if (result.Succeeded)
|
||||
|
@ -1,27 +1,22 @@
|
||||
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Security.Claims;
|
||||
using Microsoft.AspNet.Identity;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.OptionsModel;
|
||||
using Microsoft.Data.Entity;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Yavsc.Models.Workflow;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Models.Relationship;
|
||||
using Yavsc.Models.Bank;
|
||||
using Yavsc.ViewModels.Calendar;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Services;
|
||||
using Yavsc.ViewModels.Manage;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
using Yavsc.Helpers;
|
||||
using Models.Relationship;
|
||||
using Models.Bank;
|
||||
using ViewModels.Calendar;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Services;
|
||||
using Yavsc.ViewModels.Manage;
|
||||
using System.IO;
|
||||
|
||||
public class ManageController : Controller
|
||||
{
|
||||
@ -298,7 +293,7 @@ namespace Yavsc.Controllers
|
||||
public async Task<IActionResult> SetGoogleCalendar(string returnUrl, string pageToken)
|
||||
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
|
||||
var calendars = await _calendarManager.GetCalendarsAsync(pageToken);
|
||||
return View(new SetGoogleCalendarViewModel {
|
||||
@ -321,7 +316,7 @@ namespace Yavsc.Controllers
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> AddBankInfo()
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
var user = await _dbContext.Users.Include(u=>u.BankInfo).SingleAsync(u=>u.Id==uid);
|
||||
|
||||
return View(user.BankInfo);
|
||||
@ -333,7 +328,7 @@ namespace Yavsc.Controllers
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
// TODO PostBankInfoRequirement & auth
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
var user = _dbContext.Users.Include(u=>u.BankInfo)
|
||||
.Single(u=>u.Id == uid);
|
||||
|
||||
@ -496,13 +491,12 @@ namespace Yavsc.Controllers
|
||||
return View("Error");
|
||||
}
|
||||
var userLogins = await _userManager.GetLoginsAsync(user);
|
||||
var otherLogins = _signInManager.GetExternalAuthenticationSchemes().Where(auth => userLogins.All(ul => auth.AuthenticationScheme != ul.LoginProvider)).ToList();
|
||||
|
||||
ViewData["ShowRemoveButton"] = user.PasswordHash != null || userLogins.Count > 1;
|
||||
|
||||
return View(new ManageLoginsViewModel
|
||||
{
|
||||
CurrentLogins = userLogins,
|
||||
OtherLogins = otherLogins
|
||||
CurrentLogins = userLogins
|
||||
});
|
||||
}
|
||||
|
||||
@ -720,7 +714,7 @@ namespace Yavsc.Controllers
|
||||
[HttpGet]
|
||||
public async Task <IActionResult> SetAddress()
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
var user = await _dbContext.Users.Include(u=>u.PostalAddress).SingleAsync(u=>u.Id==uid);
|
||||
ViewBag.GoogleSettings = _googleSettings;
|
||||
return View (user.PostalAddress ?? new Location());
|
||||
@ -730,7 +724,7 @@ namespace Yavsc.Controllers
|
||||
public async Task <IActionResult> SetAddress(Location model)
|
||||
{
|
||||
if (ModelState.IsValid) {
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
|
||||
var user = _dbContext.Users.Include(u=>u.PostalAddress).Single(u=>u.Id==uid);
|
||||
|
||||
|
@ -1,148 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.DataProtection.KeyManagement;
|
||||
using Microsoft.AspNet.Http.Authentication;
|
||||
using Microsoft.AspNet.Identity;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.WebUtilities;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.OptionsModel;
|
||||
using Microsoft.Extensions.Primitives;
|
||||
using OAuth.AspNet.AuthServer;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Auth;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
[AllowAnonymous]
|
||||
public class OAuthController : Controller
|
||||
{
|
||||
readonly ILogger _logger;
|
||||
|
||||
public OAuthController(ILoggerFactory loggerFactory)
|
||||
{
|
||||
_logger = loggerFactory.CreateLogger<OAuthController>();
|
||||
}
|
||||
|
||||
|
||||
[HttpGet("~/api/getclaims"), Produces("application/json")]
|
||||
|
||||
public IActionResult GetClaims()
|
||||
{
|
||||
var identity = User.Identity as ClaimsIdentity;
|
||||
|
||||
var claims = from c in identity.Claims
|
||||
select new
|
||||
{
|
||||
subject = c.Subject.Name,
|
||||
type = c.Type,
|
||||
value = c.Value
|
||||
};
|
||||
|
||||
return Ok(claims);
|
||||
}
|
||||
|
||||
[HttpGet(Constants.AuthorizePath),HttpPost(Constants.AuthorizePath)]
|
||||
public async Task<ActionResult> Authorize()
|
||||
{
|
||||
if (Response.StatusCode != 200)
|
||||
{
|
||||
if (Request.Headers.Keys.Contains("Accept")) {
|
||||
var accepted = Request.Headers["Accept"];
|
||||
if (accepted.Contains("application/json"))
|
||||
{
|
||||
_logger.LogError("Invalid http status at authorisation");
|
||||
return new BadRequestObjectResult(new { error = Response.StatusCode} );
|
||||
}
|
||||
}
|
||||
|
||||
return View("AuthorizeError");
|
||||
}
|
||||
|
||||
AuthenticationManager authentication = Request.HttpContext.Authentication;
|
||||
var appAuthSheme = Startup.IdentityAppOptions.Cookies.ApplicationCookieAuthenticationScheme;
|
||||
|
||||
ClaimsPrincipal principal = await authentication.AuthenticateAsync(appAuthSheme);
|
||||
|
||||
if (principal == null)
|
||||
{
|
||||
await authentication.ChallengeAsync(appAuthSheme);
|
||||
|
||||
if (Response.StatusCode == 200)
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
return new HttpStatusCodeResult(Response.StatusCode);
|
||||
}
|
||||
|
||||
string[] scopes = { };
|
||||
string redirect_uri=null;
|
||||
|
||||
IDictionary<string,StringValues> queryStringComponents = null;
|
||||
|
||||
if (Request.QueryString.HasValue)
|
||||
{
|
||||
queryStringComponents = QueryHelpers.ParseQuery(Request.QueryString.Value);
|
||||
|
||||
if (queryStringComponents.ContainsKey("scope"))
|
||||
scopes = ((string)queryStringComponents["scope"]).Split(' ');
|
||||
if (queryStringComponents.ContainsKey("redirect_uri"))
|
||||
redirect_uri = queryStringComponents["redirect_uri"];
|
||||
}
|
||||
var username = User.GetUserName();
|
||||
|
||||
var model = new AuthorisationView {
|
||||
Scopes = (Constants.SiteScopes.Where(s=> scopes.Contains(s.Id))).ToArray(),
|
||||
Message = $"Bienvenue {username}."
|
||||
} ;
|
||||
|
||||
if (Request.Method == "POST")
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Request.Form["submit.Grant"]))
|
||||
{
|
||||
principal = new ClaimsPrincipal(principal.Identities);
|
||||
|
||||
ClaimsIdentity primaryIdentity = (ClaimsIdentity)principal.Identity;
|
||||
|
||||
foreach (var scope in scopes)
|
||||
{
|
||||
primaryIdentity.AddClaim(new Claim("urn:oauth:scope", scope));
|
||||
}
|
||||
await authentication.SignInAsync(OAuthDefaults.AuthenticationType, principal);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(Request.Form["submit.Deny"]))
|
||||
{
|
||||
await authentication.SignOutAsync(appAuthSheme);
|
||||
if (redirect_uri!=null)
|
||||
return Redirect(redirect_uri+"?error=scope-denied");
|
||||
return Redirect("/");
|
||||
}
|
||||
if (!string.IsNullOrEmpty(Request.Form["submit.Login"]))
|
||||
{
|
||||
await authentication.SignOutAsync(appAuthSheme);
|
||||
await authentication.ChallengeAsync(appAuthSheme);
|
||||
return new HttpUnauthorizedResult();
|
||||
}
|
||||
}
|
||||
|
||||
if (Request.Headers.Keys.Contains("Accept")) {
|
||||
var accepted = Request.Headers["Accept"];
|
||||
if (accepted.Contains("application/json"))
|
||||
{
|
||||
_logger.LogInformation("serving available scopes");
|
||||
return Ok(model);
|
||||
}
|
||||
}
|
||||
return View(model);
|
||||
}
|
||||
|
||||
[HttpGet("~/oauth/success")]
|
||||
public IActionResult NativeAuthSuccess ()
|
||||
{
|
||||
return RedirectToAction("Index","Home");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Models;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
@ -29,13 +29,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
ApplicationUser applicationUser = await _context.ApplicationUser.SingleAsync(m => m.Id == id);
|
||||
if (applicationUser == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(applicationUser);
|
||||
@ -68,13 +68,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
ApplicationUser applicationUser = await _context.ApplicationUser.SingleAsync(m => m.Id == id);
|
||||
if (applicationUser == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
ViewData["PostalAddressId"] = new SelectList(_context.Locations, "Id", "PostalAddress", applicationUser.PostalAddressId);
|
||||
return View(applicationUser);
|
||||
@ -101,13 +101,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
ApplicationUser applicationUser = await _context.ApplicationUser.SingleAsync(m => m.Id == id);
|
||||
if (applicationUser == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(applicationUser);
|
||||
|
@ -1,14 +1,11 @@
|
||||
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Identity;
|
||||
using Microsoft.AspNet.Identity.EntityFramework;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Abstract.Identity;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.ViewModels;
|
||||
using Yavsc.ViewModels.Administration;
|
||||
@ -75,7 +72,7 @@ namespace Yavsc.Controllers
|
||||
|
||||
return Ok(new { message = "you already got it." });
|
||||
}
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var user = await _userManager.FindByIdAsync(User.GetUserId());
|
||||
@ -105,12 +102,10 @@ namespace Yavsc.Controllers
|
||||
var youAreAdmin = await _userManager.IsInRoleAsync(
|
||||
await _userManager.FindByIdAsync(User.GetUserId()),
|
||||
Constants.AdminGroupName);
|
||||
var roles = _roleManager.Roles.Include(
|
||||
x => x.Users
|
||||
).Select(x => new RoleInfo {
|
||||
throw new NotImplementedException();
|
||||
var roles = _roleManager.Roles.Select(x => new RoleInfo {
|
||||
Id = x.Id,
|
||||
Name = x.Name,
|
||||
Users = x.Users.Select(u=>u.UserId).ToArray()
|
||||
Name = x.Name
|
||||
});
|
||||
var assembly = GetType().Assembly;
|
||||
ViewBag.ThisAssembly = assembly.FullName;
|
||||
@ -125,26 +120,6 @@ namespace Yavsc.Controllers
|
||||
});
|
||||
}
|
||||
|
||||
public IActionResult Role(string id)
|
||||
{
|
||||
IdentityRole role = _roleManager.Roles
|
||||
.Include(r=>r.Users).FirstOrDefault
|
||||
( r=> r.Id == id );
|
||||
var ri = GetRoleUserCollection(role);
|
||||
return View("Role",ri);
|
||||
}
|
||||
|
||||
public RoleUserCollection GetRoleUserCollection(IdentityRole role)
|
||||
{
|
||||
var result = new RoleUserCollection {
|
||||
Id = role.Id,
|
||||
Name = role.Name,
|
||||
Users = _dbContext.Users.Where(u=>role.Users.Any(ru => u.Id == ru.UserId))
|
||||
.Select( u => new UserInfo { UserName = u.UserName, Avatar = u.Avatar, UserId = u.Id } )
|
||||
.ToArray()
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
[Authorize("AdministratorOnly")]
|
||||
public IActionResult Enroll(string roleName)
|
||||
@ -160,7 +135,7 @@ namespace Yavsc.Controllers
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
var newAdmin = await _dbContext.Users.FirstOrDefaultAsync(u=>u.Id==model.EnroledUserId);
|
||||
if (newAdmin==null) return HttpNotFound();
|
||||
if (newAdmin==null) return NotFound();
|
||||
var addToRoleResult = await _userManager.AddToRoleAsync(newAdmin, model.RoleName);
|
||||
if (addToRoleResult.Succeeded)
|
||||
{
|
||||
@ -176,7 +151,7 @@ namespace Yavsc.Controllers
|
||||
public async Task<IActionResult> Fire(string roleName, string userId)
|
||||
{
|
||||
var user = await _dbContext.Users.FirstOrDefaultAsync(u=>u.Id==userId);
|
||||
if (user == null) return HttpNotFound();
|
||||
if (user == null) return NotFound();
|
||||
|
||||
return View(new FireViewModel{ RoleName = roleName, EnroledUserId = userId, EnroledUserName = user.UserName });
|
||||
}
|
||||
@ -188,7 +163,7 @@ namespace Yavsc.Controllers
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
var oldEnroled = await _dbContext.Users.FirstOrDefaultAsync(u=>u.Id==model.EnroledUserId);
|
||||
if (oldEnroled==null) return HttpNotFound();
|
||||
if (oldEnroled==null) return NotFound();
|
||||
var removeFromRole = await _userManager.RemoveFromRoleAsync(oldEnroled, model.RoleName);
|
||||
if (removeFromRole.Succeeded)
|
||||
{
|
||||
|
@ -1,18 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using System.Security.Claims;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Microsoft.Data.Entity;
|
||||
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Calendar;
|
||||
using Yavsc.Server.Models.EMailing;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Yavsc.Templates;
|
||||
using System.Linq;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Yavsc.Server.Settings;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Helpers;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
@ -42,13 +37,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
MailingTemplate mailingTemplate = await _context.MailingTemplate.SingleAsync(m => m.Id == id);
|
||||
if (mailingTemplate == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(mailingTemplate);
|
||||
@ -101,13 +96,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
MailingTemplate mailingTemplate = await _context.MailingTemplate.SingleAsync(m => m.Id == id);
|
||||
if (mailingTemplate == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
SetupViewBag();
|
||||
return View(mailingTemplate);
|
||||
@ -135,13 +130,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
MailingTemplate mailingTemplate = await _context.MailingTemplate.SingleAsync(m => m.Id == id);
|
||||
if (mailingTemplate == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(mailingTemplate);
|
||||
|
@ -1,13 +1,13 @@
|
||||
using System.Threading.Tasks;
|
||||
using Yavsc.ViewModels.Auth;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Messaging;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
@ -37,13 +37,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Announce announce = await _context.Announce.SingleAsync(m => m.Id == id);
|
||||
if (announce == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(announce);
|
||||
@ -60,7 +60,7 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
ViewBag.IsAdmin = User.IsInRole(Constants.AdminGroupName);
|
||||
ViewBag.IsPerformer = User.IsInRole(Constants.PerformerGroupName);
|
||||
ViewBag.AllowEdit = announce==null || announce.Id<=0 || await _authorizationService.AuthorizeAsync(User,announce,new EditRequirement());
|
||||
ViewBag.AllowEdit = announce==null || announce.Id<=0 || !_authorizationService.AuthorizeAsync(User,announce,new EditRequirement()).IsFaulted;
|
||||
List<SelectListItem> dl = new List<SelectListItem>();
|
||||
var rnames = System.Enum.GetNames(typeof(Reason));
|
||||
var rvalues = System.Enum.GetValues(typeof(Reason));
|
||||
@ -107,13 +107,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Announce announce = await _context.Announce.SingleAsync(m => m.Id == id);
|
||||
if (announce == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
return View(announce);
|
||||
}
|
||||
@ -138,13 +138,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Announce announce = await _context.Announce.SingleAsync(m => m.Id == id);
|
||||
if (announce == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(announce);
|
||||
|
@ -2,18 +2,18 @@
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Identity;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.Extensions.OptionsModel;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.ViewModels.Auth;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Yavsc.Models.Blog;
|
||||
using Yavsc.Helpers;
|
||||
using Microsoft.AspNet.Localization;
|
||||
using Microsoft.AspNetCore.Localization;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
// For more information on enabling Web API for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860
|
||||
|
||||
@ -52,7 +52,7 @@ namespace Yavsc.Controllers
|
||||
[AllowAnonymous]
|
||||
public IActionResult Title(string id)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
ViewData["Title"] = id;
|
||||
return View("Title", _context.Blogspot.Include(
|
||||
b => b.Author
|
||||
@ -75,7 +75,7 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
BlogPost blog = _context.Blogspot
|
||||
@ -86,9 +86,9 @@ namespace Yavsc.Controllers
|
||||
.Single(m => m.Id == id);
|
||||
if (blog == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
if (!await _authorizationService.AuthorizeAsync(User, blog, new ViewRequirement()))
|
||||
if ( _authorizationService.AuthorizeAsync(User, blog, new ViewRequirement()).IsFaulted)
|
||||
{
|
||||
return new ChallengeResult();
|
||||
}
|
||||
@ -141,7 +141,7 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
ViewData["PostTarget"]="Edit";
|
||||
@ -150,9 +150,9 @@ namespace Yavsc.Controllers
|
||||
|
||||
if (blog == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
if (await _authorizationService.AuthorizeAsync(User, blog, new EditRequirement()))
|
||||
if (!_authorizationService.AuthorizeAsync(User, blog, new EditRequirement()).IsFaulted)
|
||||
{
|
||||
ViewBag.ACL = _context.Circle.Where(
|
||||
c=>c.OwnerId == blog.AuthorId)
|
||||
@ -181,7 +181,7 @@ namespace Yavsc.Controllers
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
var auth = _authorizationService.AuthorizeAsync(User, blog, new EditRequirement());
|
||||
if (auth.Result)
|
||||
if (!auth.IsFaulted)
|
||||
{
|
||||
// saves the change
|
||||
_context.Update(blog);
|
||||
@ -205,7 +205,7 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
BlogPost blog = _context.Blogspot.Include(
|
||||
@ -213,7 +213,7 @@ namespace Yavsc.Controllers
|
||||
).Single(m => m.Id == id);
|
||||
if (blog == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(blog);
|
||||
@ -224,13 +224,11 @@ namespace Yavsc.Controllers
|
||||
[ValidateAntiForgeryToken]
|
||||
public IActionResult DeleteConfirmed(long id)
|
||||
{
|
||||
BlogPost blog = _context.Blogspot.Single(m => m.Id == id);
|
||||
var auth = _authorizationService.AuthorizeAsync(User, blog, new EditRequirement());
|
||||
if (auth.Result)
|
||||
{
|
||||
_context.Blogspot.Remove(blog);
|
||||
_context.SaveChanges(User.GetUserId());
|
||||
}
|
||||
BlogPost blog = _context.Blogspot.Single(m => m.Id == id && m.GetOwnerId()== User.GetUserId());
|
||||
|
||||
_context.Blogspot.Remove(blog);
|
||||
_context.SaveChanges(User.GetUserId());
|
||||
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,8 @@
|
||||
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Relationship;
|
||||
|
||||
@ -29,16 +28,16 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Circle circle = await _context.Circle.SingleAsync(m => m.Id == id);
|
||||
if (circle == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
var uid = User.GetUserId();
|
||||
if (uid != circle.OwnerId) return this.HttpUnauthorized();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (uid != circle.OwnerId) return this.Unauthorized();
|
||||
return View(circle);
|
||||
}
|
||||
|
||||
@ -53,11 +52,11 @@ namespace Yavsc.Controllers
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Create(Circle circle)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
if (uid != circle.OwnerId)
|
||||
return this.HttpUnauthorized();
|
||||
return this.Unauthorized();
|
||||
|
||||
_context.Circle.Add(circle);
|
||||
await _context.SaveChangesAsync(uid);
|
||||
@ -71,18 +70,18 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Circle circle = await _context.Circle.SingleAsync(m => m.Id == id);
|
||||
|
||||
if (circle == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (uid != circle.OwnerId)
|
||||
return this.HttpUnauthorized();
|
||||
return Unauthorized();
|
||||
return View(circle);
|
||||
}
|
||||
|
||||
@ -94,8 +93,8 @@ namespace Yavsc.Controllers
|
||||
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
if (uid != circle.OwnerId) return this.HttpUnauthorized();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (uid != circle.OwnerId) return Unauthorized();
|
||||
_context.Update(circle);
|
||||
await _context.SaveChangesAsync(uid);
|
||||
return RedirectToAction("Index");
|
||||
@ -109,16 +108,16 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Circle circle = await _context.Circle.SingleAsync(m => m.Id == id);
|
||||
if (circle == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
var uid = User.GetUserId();
|
||||
if (uid != circle.OwnerId) return this.HttpUnauthorized();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (uid != circle.OwnerId) return Unauthorized();
|
||||
|
||||
return View(circle);
|
||||
}
|
||||
@ -129,8 +128,8 @@ namespace Yavsc.Controllers
|
||||
public async Task<IActionResult> DeleteConfirmed(long id)
|
||||
{
|
||||
Circle circle = await _context.Circle.SingleAsync(m => m.Id == id);
|
||||
var uid = User.GetUserId();
|
||||
if (uid != circle.OwnerId) return this.HttpUnauthorized();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (uid != circle.OwnerId) return Unauthorized();
|
||||
_context.Circle.Remove(circle);
|
||||
await _context.SaveChangesAsync(uid);
|
||||
return RedirectToAction("Index");
|
||||
|
@ -1,9 +1,9 @@
|
||||
using System.Linq;
|
||||
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Relationship;
|
||||
|
||||
@ -21,7 +21,7 @@ namespace Yavsc.Controllers
|
||||
// GET: CircleMembers
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
var applicationDbContext = _context.CircleMembers.Include(c => c.Circle).Include(c => c.Member)
|
||||
.Where(c=>c.Circle.OwnerId == uid);
|
||||
return View(await applicationDbContext.ToListAsync());
|
||||
@ -30,14 +30,14 @@ namespace Yavsc.Controllers
|
||||
// GET: CircleMembers/Details/5
|
||||
public async Task<IActionResult> Details(long id)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
|
||||
CircleMember circleMember = await _context.CircleMembers
|
||||
.Include(m=>m.Circle)
|
||||
.FirstOrDefaultAsync(c=>c.CircleId == id);
|
||||
if (circleMember == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(circleMember);
|
||||
@ -46,7 +46,7 @@ namespace Yavsc.Controllers
|
||||
// GET: CircleMembers/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
ViewBag.CircleId = new SelectList(_context.Circle.Where(c=>c.OwnerId == uid), "Id", "Name");
|
||||
ViewBag.MemberId = new SelectList(_context.Users, "Id", "UserName");
|
||||
return View();
|
||||
@ -57,7 +57,7 @@ namespace Yavsc.Controllers
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Create(CircleMember circleMember)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
var circle = _context.Circle.SingleOrDefault(c=>c.OwnerId == uid && c.Id == circleMember.CircleId);
|
||||
if (circle==null)
|
||||
return new BadRequestResult();
|
||||
@ -76,13 +76,13 @@ namespace Yavsc.Controllers
|
||||
// GET: CircleMembers/Edit/5
|
||||
public async Task<IActionResult> Edit(long id)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
CircleMember circleMember = await _context.CircleMembers
|
||||
.Include(m=>m.Member)
|
||||
.SingleOrDefaultAsync(m => m.CircleId == id && m.MemberId == uid);
|
||||
if (circleMember == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
return View(circleMember);
|
||||
}
|
||||
@ -107,7 +107,7 @@ namespace Yavsc.Controllers
|
||||
[ActionName("Delete")]
|
||||
public async Task<IActionResult> Delete(long id)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
|
||||
CircleMember circleMember = await _context.CircleMembers
|
||||
.Include(m=>m.Circle)
|
||||
@ -115,7 +115,7 @@ namespace Yavsc.Controllers
|
||||
.SingleOrDefaultAsync(m => m.CircleId == id && m.MemberId == uid);
|
||||
if (circleMember == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(circleMember);
|
||||
|
@ -1,8 +1,8 @@
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Microsoft.Data.Entity;
|
||||
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Blog;
|
||||
|
||||
@ -32,13 +32,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Comment comment = await _context.Comment.SingleAsync(m => m.Id == id);
|
||||
if (comment == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(comment);
|
||||
@ -73,13 +73,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Comment comment = await _context.Comment.SingleAsync(m => m.Id == id);
|
||||
if (comment == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
ViewData["PostId"] = new SelectList(_context.Blogspot, "Id", "Post", comment.PostId);
|
||||
return View(comment);
|
||||
@ -106,13 +106,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Comment comment = await _context.Comment.SingleAsync(m => m.Id == id);
|
||||
if (comment == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(comment);
|
||||
|
@ -1,13 +1,11 @@
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using System.Security.Claims;
|
||||
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Models;
|
||||
using Models.Identity;
|
||||
public class DevicesController : Controller
|
||||
@ -22,7 +20,7 @@ namespace Yavsc.Controllers
|
||||
// GET: GCMDevices
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
|
||||
var applicationDbContext = _context.DeviceDeclaration.Include(g => g.DeviceOwner).Where(d=>d.DeviceOwnerId == uid);
|
||||
return View(await applicationDbContext.ToListAsync());
|
||||
@ -33,13 +31,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
DeviceDeclaration googleCloudMobileDeclaration = await _context.DeviceDeclaration.SingleAsync(m => m.DeviceId == id);
|
||||
if (googleCloudMobileDeclaration == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(googleCloudMobileDeclaration);
|
||||
@ -51,13 +49,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
DeviceDeclaration googleCloudMobileDeclaration = await _context.DeviceDeclaration.SingleAsync(m => m.DeviceId == id);
|
||||
if (googleCloudMobileDeclaration == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(googleCloudMobileDeclaration);
|
||||
|
@ -1,7 +1,6 @@
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Relationship;
|
||||
|
||||
@ -28,13 +27,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (href == null || method ==null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
HyperLink hyperLink = await _context.HyperLink.SingleAsync(m => m.HRef == href && m.Method == method);
|
||||
if (hyperLink == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(hyperLink);
|
||||
@ -65,13 +64,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (href == null || method ==null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
HyperLink hyperLink = await _context.HyperLink.SingleAsync(m => m.HRef == href && m.Method == method);
|
||||
if (hyperLink == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
return View(hyperLink);
|
||||
}
|
||||
@ -96,14 +95,14 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (href == null || method ==null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
HyperLink hyperLink = await _context.HyperLink.SingleAsync(m => m.HRef == href && m.Method == method);
|
||||
|
||||
if (hyperLink == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(hyperLink);
|
||||
@ -116,7 +115,7 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (HRef == null || Method ==null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
HyperLink hyperLink = await _context.HyperLink.SingleAsync(m => m.HRef == HRef && m.Method == Method);
|
||||
|
@ -1,7 +1,6 @@
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Messaging;
|
||||
|
||||
@ -27,13 +26,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Notification notification = await _context.Notification.SingleAsync(m => m.Id == id);
|
||||
if (notification == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(notification);
|
||||
@ -64,13 +63,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Notification notification = await _context.Notification.SingleAsync(m => m.Id == id);
|
||||
if (notification == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
return View(notification);
|
||||
}
|
||||
@ -95,13 +94,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Notification notification = await _context.Notification.SingleAsync(m => m.Id == id);
|
||||
if (notification == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(notification);
|
||||
|
@ -1,17 +1,14 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
using System.Security.Claims;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Models;
|
||||
using Models.Workflow;
|
||||
using Yavsc.Helpers;
|
||||
|
||||
[Authorize("AdministratorOnly")]
|
||||
public class ActivityController : Controller
|
||||
@ -105,13 +102,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Activity activity = _context.Activities.Single(m => m.Code == id);
|
||||
if (activity == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(activity);
|
||||
@ -150,13 +147,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Activity activity = _context.Activities.Single(m => m.Code == id);
|
||||
if (activity == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
ViewBag.ParentCode = GetEligibleParent(id);
|
||||
SetSettingClasseInfo();
|
||||
@ -187,13 +184,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Activity activity = _context.Activities.Single(m => m.Code == id);
|
||||
if (activity == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(activity);
|
||||
|
@ -1,12 +1,9 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Microsoft.Data.Entity;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Auth;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
@ -30,13 +27,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Client client = await _context.Applications.SingleAsync(m => m.Id == id);
|
||||
if (client == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
return View(client);
|
||||
}
|
||||
@ -81,13 +78,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Client client = await _context.Applications.SingleAsync(m => m.Id == id);
|
||||
if (client == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
SetAppTypesInputValues();
|
||||
return View(client);
|
||||
@ -113,13 +110,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Client client = await _context.Applications.SingleAsync(m => m.Id == id);
|
||||
if (client == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(client);
|
||||
|
@ -1,9 +1,7 @@
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Workflow;
|
||||
|
||||
@ -30,13 +28,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
CoWorking coWorking = await _context.CoWorking.SingleAsync(m => m.Id == id);
|
||||
if (coWorking == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(coWorking);
|
||||
@ -71,13 +69,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
CoWorking coWorking = await _context.CoWorking.SingleAsync(m => m.Id == id);
|
||||
if (coWorking == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
ViewData["PerformerId"] = new SelectList(_context.Performers, "PerformerId", "Performer", coWorking.PerformerId);
|
||||
ViewData["WorkingForId"] = new SelectList(_context.Users, "Id", "WorkingFor", coWorking.WorkingForId);
|
||||
@ -106,13 +104,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
CoWorking coWorking = await _context.CoWorking.SingleAsync(m => m.Id == id);
|
||||
if (coWorking == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(coWorking);
|
||||
|
@ -1,18 +1,14 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Identity;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.OptionsModel;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
using Helpers;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Models;
|
||||
using Models.Google.Messaging;
|
||||
using Models.Relationship;
|
||||
@ -58,7 +54,7 @@ namespace Yavsc.Controllers
|
||||
[Authorize]
|
||||
public virtual async Task<IActionResult> Index()
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
return View(await _context.RdvQueries
|
||||
.Include(x => x.Client)
|
||||
.Include(x => x.PerformerProfile)
|
||||
@ -77,7 +73,7 @@ namespace Yavsc.Controllers
|
||||
.SingleAsync(m => m.Id == id);
|
||||
if (command == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(command);
|
||||
@ -105,7 +101,7 @@ namespace Yavsc.Controllers
|
||||
x => x.PerformerId == proId
|
||||
);
|
||||
if (pro == null)
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
ViewBag.Activity = _context.Activities.FirstOrDefault(a => a.Code == activityCode);
|
||||
ViewBag.GoogleSettings = _googleSettings;
|
||||
var userid = User.GetUserId();
|
||||
@ -126,7 +122,7 @@ namespace Yavsc.Controllers
|
||||
public async Task<IActionResult> Create(RdvQuery command)
|
||||
{
|
||||
// TODO validate BillingCode value
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
var prid = command.PerformerId;
|
||||
if (string.IsNullOrWhiteSpace(uid)
|
||||
|| string.IsNullOrWhiteSpace(prid))
|
||||
@ -156,7 +152,7 @@ namespace Yavsc.Controllers
|
||||
command.Location = existingLocation;
|
||||
}
|
||||
else _context.Attach<Location>(command.Location);
|
||||
_context.RdvQueries.Add(command, GraphBehavior.IncludeDependents);
|
||||
_context.RdvQueries.Add(command);
|
||||
_context.SaveChanges(User.GetUserId());
|
||||
|
||||
var yaev = command.CreateEvent("NewCommand");
|
||||
@ -213,13 +209,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
RdvQuery command = _context.RdvQueries.Single(m => m.Id == id);
|
||||
if (command == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
return View(command);
|
||||
}
|
||||
@ -244,13 +240,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
RdvQuery command = _context.RdvQueries.Single(m => m.Id == id);
|
||||
if (command == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(command);
|
||||
|
@ -1,9 +1,7 @@
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Workflow;
|
||||
|
||||
@ -30,13 +28,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
CommandForm commandForm = await _context.CommandForm.SingleAsync(m => m.Id == id);
|
||||
if (commandForm == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(commandForm);
|
||||
@ -73,13 +71,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
CommandForm commandForm = await _context.CommandForm.SingleAsync(m => m.Id == id);
|
||||
if (commandForm == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
SetViewBag(commandForm);
|
||||
return View(commandForm);
|
||||
@ -106,13 +104,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
CommandForm commandForm = await _context.CommandForm.SingleAsync(m => m.Id == id);
|
||||
if (commandForm == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(commandForm);
|
||||
|
@ -1,6 +1,5 @@
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Musical.Profiles;
|
||||
|
||||
@ -26,13 +25,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
DjSettings djSettings = await _context.DjSettings.SingleAsync(m => m.UserId == id);
|
||||
if (djSettings == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(djSettings);
|
||||
@ -63,13 +62,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
DjSettings djSettings = await _context.DjSettings.SingleAsync(m => m.UserId == id);
|
||||
if (djSettings == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
return View(djSettings);
|
||||
}
|
||||
@ -94,13 +93,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
DjSettings djSettings = await _context.DjSettings.SingleAsync(m => m.UserId == id);
|
||||
if (djSettings == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(djSettings);
|
||||
|
@ -1,9 +1,7 @@
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
@ -13,6 +11,8 @@ namespace Yavsc.Controllers
|
||||
using Yavsc.ViewModels.Workflow;
|
||||
using Yavsc.Services;
|
||||
using System.Threading.Tasks;
|
||||
using Yavsc.Helpers;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
[Authorize]
|
||||
public class DoController : Controller
|
||||
@ -49,14 +49,14 @@ namespace Yavsc.Controllers
|
||||
|
||||
if (id == null || activityCode == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
UserActivity userActivity = dbContext.UserActivities.Include(m=>m.Does)
|
||||
.Include(m=>m.User).Single(m => m.DoesCode == activityCode && m.UserId == id);
|
||||
if (userActivity == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
bool hasConfigurableSettings = (userActivity.Does.SettingsClassName != null);
|
||||
var settings = await billing.GetPerformerSettingsAsync(activityCode,id);
|
||||
@ -88,7 +88,7 @@ namespace Yavsc.Controllers
|
||||
[ValidateAntiForgeryToken]
|
||||
public IActionResult Create(UserActivity userActivity)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (!User.IsInRole("Administrator"))
|
||||
if (uid != userActivity.UserId)
|
||||
ModelState.AddModelError("User","You're not admin.");
|
||||
@ -110,7 +110,7 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
UserActivity userActivity = dbContext.UserActivities.Include(
|
||||
@ -120,7 +120,7 @@ namespace Yavsc.Controllers
|
||||
).Single(m => m.DoesCode == activityCode && m.UserId == id);
|
||||
if (userActivity == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
ViewData["DoesCode"] = new SelectList(dbContext.Activities, "Code", "Does", userActivity.DoesCode);
|
||||
ViewData["UserId"] = new SelectList(dbContext.Performers, "PerformerId", "User", userActivity.UserId);
|
||||
@ -152,14 +152,14 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
UserActivity userActivity = dbContext.UserActivities.Single(m => m.UserId == id && m.DoesCode == activityCode);
|
||||
|
||||
if (userActivity == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
if (!User.IsInRole("Administrator"))
|
||||
if (User.GetUserId() != userActivity.UserId)
|
||||
|
@ -1,18 +1,13 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Mime;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.Extensions.OptionsModel;
|
||||
using Yavsc.Helpers;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Yavsc.Helpers;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Models;
|
||||
using Models.Billing;
|
||||
using Models.Workflow;
|
||||
@ -36,7 +31,7 @@ namespace Yavsc.Controllers
|
||||
|
||||
public IActionResult Index()
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
return View(_context.Estimates.Include(e=>e.Query)
|
||||
.Include(e=>e.Query.PerformerProfile)
|
||||
.Include(e=>e.Query.PerformerProfile.Performer)
|
||||
@ -49,10 +44,10 @@ namespace Yavsc.Controllers
|
||||
// GET: Estimate/Details/5
|
||||
public async Task<IActionResult> Details(long? id)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Estimate estimate = _context.Estimates
|
||||
@ -66,9 +61,9 @@ namespace Yavsc.Controllers
|
||||
.Single(m => m.Id == id);
|
||||
if (estimate == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
if (!await authorizationService.AuthorizeAsync(User, estimate, new ViewRequirement()))
|
||||
if (authorizationService.AuthorizeAsync(User, estimate, new ViewRequirement()).IsFaulted)
|
||||
{
|
||||
return new ChallengeResult();
|
||||
}
|
||||
@ -80,7 +75,7 @@ namespace Yavsc.Controllers
|
||||
[Authorize]
|
||||
public IActionResult Create()
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
IQueryable<RdvQuery> queries = _context.RdvQueries.Include(q=>q.Location).Where(bq=>bq.PerformerId == uid);
|
||||
//.Select(bq=>new SelectListItem{ Text = bq.Client.UserName, Value = bq.Client.Id });
|
||||
ViewBag.Clients = queries.Select(q=>q.Client).Distinct();
|
||||
@ -147,15 +142,15 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
|
||||
Estimate estimate = _context.Estimates
|
||||
.Where(e=>e.OwnerId==uid||e.ClientId==uid).Single(m => m.Id == id);
|
||||
if (estimate == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
ViewBag.Files = Yavsc.Helpers.FileSystemHelpers.GetFileName(null);
|
||||
@ -170,9 +165,9 @@ namespace Yavsc.Controllers
|
||||
[ValidateAntiForgeryToken]
|
||||
public IActionResult Edit(Estimate estimate)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (estimate.OwnerId!=uid&&estimate.ClientId!=uid
|
||||
) return new HttpNotFoundResult();
|
||||
) return NotFound();
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Update(estimate);
|
||||
@ -188,15 +183,15 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
|
||||
Estimate estimate = _context.Estimates
|
||||
.Where(e=>e.OwnerId==uid||e.ClientId==uid) .Single(m => m.Id == id);
|
||||
if (estimate == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(estimate);
|
||||
|
@ -1,7 +1,6 @@
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Forms;
|
||||
|
||||
@ -27,13 +26,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Form form = await _context.Form.SingleAsync(m => m.Id == id);
|
||||
if (form == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(form);
|
||||
@ -64,13 +63,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Form form = await _context.Form.SingleAsync(m => m.Id == id);
|
||||
if (form == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
return View(form);
|
||||
}
|
||||
@ -95,13 +94,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Form form = await _context.Form.SingleAsync(m => m.Id == id);
|
||||
if (form == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(form);
|
||||
|
@ -1,19 +1,15 @@
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Identity;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
using Helpers;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Models;
|
||||
using ViewModels.FrontOffice;
|
||||
using Yavsc.Abstract.FileSystem;
|
||||
using Yavsc.Services;
|
||||
|
||||
public class FrontOfficeController : Controller
|
||||
@ -38,7 +34,7 @@ namespace Yavsc.Controllers
|
||||
}
|
||||
public ActionResult Index()
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
var now = DateTime.Now;
|
||||
|
||||
var model = new FrontOfficeIndexViewModel
|
||||
|
@ -1,6 +1,5 @@
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Musical.Profiles;
|
||||
|
||||
@ -26,13 +25,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
GeneralSettings generalSettings = await _context.GeneralSettings.SingleAsync(m => m.UserId == id);
|
||||
if (generalSettings == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(generalSettings);
|
||||
@ -63,13 +62,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
GeneralSettings generalSettings = await _context.GeneralSettings.SingleAsync(m => m.UserId == id);
|
||||
if (generalSettings == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
return View(generalSettings);
|
||||
}
|
||||
@ -94,13 +93,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
GeneralSettings generalSettings = await _context.GeneralSettings.SingleAsync(m => m.UserId == id);
|
||||
if (generalSettings == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(generalSettings);
|
||||
|
@ -1,11 +1,11 @@
|
||||
using System.Linq;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
using System.Security.Claims;
|
||||
using Models;
|
||||
using Models.Musical;
|
||||
using Yavsc.Helpers;
|
||||
|
||||
public class MusicalTendenciesController : Controller
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
@ -26,13 +26,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
MusicalTendency musicalTendency = _context.MusicalTendency.Single(m => m.Id == id);
|
||||
if (musicalTendency == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(musicalTendency);
|
||||
@ -63,13 +63,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
MusicalTendency musicalTendency = _context.MusicalTendency.Single(m => m.Id == id);
|
||||
if (musicalTendency == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
return View(musicalTendency);
|
||||
}
|
||||
@ -94,13 +94,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
MusicalTendency musicalTendency = _context.MusicalTendency.Single(m => m.Id == id);
|
||||
if (musicalTendency == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(musicalTendency);
|
||||
|
@ -1,7 +1,6 @@
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Billing;
|
||||
|
||||
@ -28,13 +27,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
ExceptionSIREN exceptionSIREN = _context.ExceptionsSIREN.Single(m => m.SIREN == id);
|
||||
if (exceptionSIREN == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(exceptionSIREN);
|
||||
@ -65,13 +64,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
ExceptionSIREN exceptionSIREN = _context.ExceptionsSIREN.Single(m => m.SIREN == id);
|
||||
if (exceptionSIREN == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
return View(exceptionSIREN);
|
||||
}
|
||||
@ -96,13 +95,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
ExceptionSIREN exceptionSIREN = _context.ExceptionsSIREN.Single(m => m.SIREN == id);
|
||||
if (exceptionSIREN == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(exceptionSIREN);
|
||||
|
@ -1,4 +1,4 @@
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Yavsc.Helpers;
|
||||
|
||||
|
@ -1,13 +1,12 @@
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Yavsc.Controllers.Generic
|
||||
{
|
||||
using System.Linq;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Models;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Services;
|
||||
|
||||
[Authorize]
|
||||
@ -48,7 +47,7 @@ namespace Yavsc.Controllers.Generic
|
||||
var profile = await Settings.SingleAsync(m => m.UserId == id);
|
||||
if (profile == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(profile);
|
||||
@ -85,13 +84,13 @@ namespace Yavsc.Controllers.Generic
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var brusherProfile = await Settings.SingleAsync(m => m.UserId == id);
|
||||
if (brusherProfile == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(brusherProfile);
|
||||
|
@ -1,6 +1,6 @@
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Haircut;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Yavsc.Controllers.Generic;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
|
@ -1,7 +1,6 @@
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Drawing;
|
||||
|
||||
@ -27,13 +26,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Color color = await _context.Color.SingleAsync(m => m.Id == id);
|
||||
if (color == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(color);
|
||||
@ -64,13 +63,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Color color = await _context.Color.SingleAsync(m => m.Id == id);
|
||||
if (color == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
return View(color);
|
||||
}
|
||||
@ -95,13 +94,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Color color = await _context.Color.SingleAsync(m => m.Id == id);
|
||||
if (color == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(color);
|
||||
|
@ -1,14 +1,8 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Identity;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.OptionsModel;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
@ -18,14 +12,16 @@ namespace Yavsc.Controllers
|
||||
using Yavsc.Models.Relationship;
|
||||
using Yavsc.Services;
|
||||
using Newtonsoft.Json;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Yavsc.Extensions;
|
||||
using Yavsc.Models.Haircut;
|
||||
using System.Globalization;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using System.Collections.Generic;
|
||||
using Yavsc.Models.Messaging;
|
||||
using PayPal.PayPalAPIInterfaceService.Model;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
public class HairCutCommandController : CommandController
|
||||
{
|
||||
@ -65,7 +61,7 @@ namespace Yavsc.Controllers
|
||||
HairCutQuery command = await GetQuery(id);
|
||||
if (command == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
SetViewBagPaymentUrls(id);
|
||||
return View(command);
|
||||
@ -75,7 +71,7 @@ namespace Yavsc.Controllers
|
||||
HairCutQuery command = await GetQuery(id);
|
||||
if (command == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
var paymentInfo = await _context.ConfirmPayment(User.GetUserId(), PayerID, token);
|
||||
ViewData["paymentinfo"] = paymentInfo;
|
||||
@ -139,9 +135,9 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
var query = await GetQuery(id); if (query == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (query.ClientId != uid)
|
||||
return new ChallengeResult();
|
||||
_context.HairCutQueries.Remove(query);
|
||||
@ -154,7 +150,7 @@ namespace Yavsc.Controllers
|
||||
/// <returns></returns>
|
||||
public override async Task<IActionResult> Index()
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
return View("Index", await _context.HairCutQueries
|
||||
.Include(x => x.Client)
|
||||
.Include(x => x.PerformerProfile)
|
||||
@ -175,7 +171,7 @@ namespace Yavsc.Controllers
|
||||
.SingleOrDefaultAsync(m => m.Id == id);
|
||||
if (command == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
SetViewBagPaymentUrls(id);
|
||||
return View(command);
|
||||
@ -194,7 +190,7 @@ namespace Yavsc.Controllers
|
||||
public async Task<IActionResult> CreateHairCutQuery(HairCutQuery model, string taintIds)
|
||||
{
|
||||
// TODO utiliser Markdown-av+tags
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
model.ClientId = uid;
|
||||
|
||||
var prid = model.PerformerId;
|
||||
@ -335,7 +331,7 @@ namespace Yavsc.Controllers
|
||||
pPrestation = new HairPrestation { };
|
||||
}
|
||||
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
var user = await _userManager.FindByIdAsync(uid);
|
||||
|
||||
SetViewData(activityCode, performerId, pPrestation);
|
||||
@ -381,7 +377,7 @@ namespace Yavsc.Controllers
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> CreateHairMultiCutQuery(HairMultiCutQuery command)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
var prid = command.PerformerId;
|
||||
if (string.IsNullOrWhiteSpace(uid)
|
||||
|| string.IsNullOrWhiteSpace(prid))
|
||||
@ -415,7 +411,7 @@ namespace Yavsc.Controllers
|
||||
}
|
||||
else _context.Attach<Location>(command.Location);
|
||||
|
||||
_context.HairMultiCutQueries.Add(command, GraphBehavior.IncludeDependents);
|
||||
_context.HairMultiCutQueries.Add(command);
|
||||
_context.SaveChanges(User.GetUserId());
|
||||
var brSettings = await _context.BrusherProfile.SingleAsync(
|
||||
bp => bp.UserId == command.PerformerId
|
||||
|
@ -1,6 +1,5 @@
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Haircut;
|
||||
|
||||
@ -26,13 +25,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
HairPrestation hairPrestation = await _context.HairPrestation.SingleAsync(m => m.Id == id);
|
||||
if (hairPrestation == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(hairPrestation);
|
||||
@ -63,13 +62,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
HairPrestation hairPrestation = await _context.HairPrestation.SingleAsync(m => m.Id == id);
|
||||
if (hairPrestation == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
return View(hairPrestation);
|
||||
}
|
||||
@ -94,13 +93,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
HairPrestation hairPrestation = await _context.HairPrestation.SingleAsync(m => m.Id == id);
|
||||
if (hairPrestation == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(hairPrestation);
|
||||
|
@ -1,9 +1,8 @@
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Haircut;
|
||||
|
||||
@ -31,13 +30,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
HairTaint hairTaint = await _context.HairTaint.SingleAsync(m => m.Id == id);
|
||||
if (hairTaint == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(hairTaint);
|
||||
@ -70,13 +69,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
HairTaint hairTaint = await _context.HairTaint.SingleAsync(m => m.Id == id);
|
||||
if (hairTaint == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
ViewBag.ColorId = new SelectList(_context.Color, "Id", "Name",hairTaint.ColorId);
|
||||
return View(hairTaint);
|
||||
@ -103,13 +102,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
HairTaint hairTaint = await _context.HairTaint.SingleAsync(m => m.Id == id);
|
||||
if (hairTaint == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(hairTaint);
|
||||
|
@ -1,135 +1,31 @@
|
||||
using Microsoft.AspNet.Mvc.Localization;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Http.Features;
|
||||
using Microsoft.AspNet.Diagnostics;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Hosting;
|
||||
using Microsoft.AspNet.Identity;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNet.Http;
|
||||
using System.Threading.Tasks;
|
||||
using System.Diagnostics;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Yavsc.Models;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
namespace Yavsc.Controllers;
|
||||
|
||||
public class HomeController : Controller
|
||||
{
|
||||
using System.IO;
|
||||
using Models;
|
||||
using Yavsc;
|
||||
using Yavsc.Helpers;
|
||||
private readonly ILogger<HomeController> _logger;
|
||||
|
||||
[AllowAnonymous]
|
||||
public class HomeController : Controller
|
||||
public HomeController(ILogger<HomeController> logger)
|
||||
{
|
||||
readonly ApplicationDbContext _dbContext;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
readonly IHtmlLocalizer _localizer;
|
||||
public HomeController(IHtmlLocalizer<Startup> localizer,
|
||||
ApplicationDbContext context)
|
||||
{
|
||||
_localizer = localizer;
|
||||
_dbContext = context;
|
||||
}
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Index(string id)
|
||||
{
|
||||
ViewBag.IsFromSecureProx = Request.Headers.ContainsKey(Constants.SshHeaderKey) && Request.Headers[Constants.SshHeaderKey] == "on";
|
||||
ViewBag.SecureHomeUrl = "https://" + Request.Headers["X-Forwarded-Host"];
|
||||
ViewBag.SshHeaderKey = Request.Headers[Constants.SshHeaderKey];
|
||||
var uid = User.GetUserId();
|
||||
long[] clicked = null;
|
||||
if (uid == null)
|
||||
{
|
||||
await HttpContext.Session.LoadAsync();
|
||||
var strclicked = HttpContext.Session.GetString("clicked");
|
||||
if (strclicked != null) clicked = strclicked.Split(':').Select(c => long.Parse(c)).ToArray();
|
||||
if (clicked == null) clicked = new long[0];
|
||||
}
|
||||
else clicked = _dbContext.DimissClicked.Where(d => d.UserId == uid).Select(d => d.NotificationId).ToArray();
|
||||
var notes = _dbContext.Notification.Where(
|
||||
n => !clicked.Contains(n.Id)
|
||||
);
|
||||
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)
|
||||
{
|
||||
a.Children = a.Children.Where(c => !c.Hidden).ToList();
|
||||
}
|
||||
return View(toShow);
|
||||
}
|
||||
public async Task<IActionResult> About()
|
||||
{
|
||||
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."]);
|
||||
}
|
||||
public IActionResult Privacy()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
public IActionResult AboutMarkdown()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult Contact()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
public IActionResult Dash()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
public ActionResult Chat()
|
||||
{
|
||||
if (User.Identity.IsAuthenticated)
|
||||
{
|
||||
ViewBag.IsAuthenticated = true;
|
||||
string uid = User.GetUserId();
|
||||
ViewBag.Contacts = _dbContext.Contact.Where(c => c.OwnerId == uid)
|
||||
;
|
||||
}
|
||||
else ViewBag.IsAuthenticated = false;
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult Error()
|
||||
{
|
||||
var feature = this.HttpContext.Features.Get<IExceptionHandlerFeature>();
|
||||
|
||||
return View("~/Views/Shared/Error.cshtml", feature?.Error);
|
||||
}
|
||||
public IActionResult Status(int id)
|
||||
{
|
||||
ViewBag.StatusCode = id;
|
||||
return View("~/Views/Shared/Status.cshtml");
|
||||
}
|
||||
public IActionResult Todo()
|
||||
{
|
||||
User.GetUserId();
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult VideoChat()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult Audio()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
public IActionResult Privacy()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public IActionResult Error()
|
||||
{
|
||||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||
}
|
||||
}
|
||||
|
135
src/Yavsc/Controllers/HomeController.cs.old
Normal file
135
src/Yavsc/Controllers/HomeController.cs.old
Normal file
@ -0,0 +1,135 @@
|
||||
using Microsoft.AspNet.Mvc.Localization;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Http.Features;
|
||||
using Microsoft.AspNet.Diagnostics;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Hosting;
|
||||
using Microsoft.AspNet.Identity;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNet.Http;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
using System.IO;
|
||||
using Models;
|
||||
using Yavsc;
|
||||
using Yavsc.Helpers;
|
||||
|
||||
[AllowAnonymous]
|
||||
public class HomeController : Controller
|
||||
{
|
||||
readonly ApplicationDbContext _dbContext;
|
||||
|
||||
readonly IHtmlLocalizer _localizer;
|
||||
public HomeController(IHtmlLocalizer<Startup> localizer,
|
||||
ApplicationDbContext context)
|
||||
{
|
||||
_localizer = localizer;
|
||||
_dbContext = context;
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Index(string id)
|
||||
{
|
||||
ViewBag.IsFromSecureProx = Request.Headers.ContainsKey(Constants.SshHeaderKey) && Request.Headers[Constants.SshHeaderKey] == "on";
|
||||
ViewBag.SecureHomeUrl = "https://" + Request.Headers["X-Forwarded-Host"];
|
||||
ViewBag.SshHeaderKey = Request.Headers[Constants.SshHeaderKey];
|
||||
var uid = User.GetUserId();
|
||||
long[] clicked = null;
|
||||
if (uid == null)
|
||||
{
|
||||
await HttpContext.Session.LoadAsync();
|
||||
var strclicked = HttpContext.Session.GetString("clicked");
|
||||
if (strclicked != null) clicked = strclicked.Split(':').Select(c => long.Parse(c)).ToArray();
|
||||
if (clicked == null) clicked = new long[0];
|
||||
}
|
||||
else clicked = _dbContext.DimissClicked.Where(d => d.UserId == uid).Select(d => d.NotificationId).ToArray();
|
||||
var notes = _dbContext.Notification.Where(
|
||||
n => !clicked.Contains(n.Id)
|
||||
);
|
||||
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)
|
||||
{
|
||||
a.Children = a.Children.Where(c => !c.Hidden).ToList();
|
||||
}
|
||||
return View(toShow);
|
||||
}
|
||||
public async Task<IActionResult> About()
|
||||
{
|
||||
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."]);
|
||||
}
|
||||
public IActionResult Privacy()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
public IActionResult AboutMarkdown()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult Contact()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
public IActionResult Dash()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
public ActionResult Chat()
|
||||
{
|
||||
if (User.Identity.IsAuthenticated)
|
||||
{
|
||||
ViewBag.IsAuthenticated = true;
|
||||
string uid = User.GetUserId();
|
||||
ViewBag.Contacts = _dbContext.Contact.Where(c => c.OwnerId == uid)
|
||||
;
|
||||
}
|
||||
else ViewBag.IsAuthenticated = false;
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult Error()
|
||||
{
|
||||
var feature = this.HttpContext.Features.Get<IExceptionHandlerFeature>();
|
||||
|
||||
return View("~/Views/Shared/Error.cshtml", feature?.Error);
|
||||
}
|
||||
public IActionResult Status(int id)
|
||||
{
|
||||
ViewBag.StatusCode = id;
|
||||
return View("~/Views/Shared/Status.cshtml");
|
||||
}
|
||||
public IActionResult Todo()
|
||||
{
|
||||
User.GetUserId();
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult VideoChat()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult Audio()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,13 +1,10 @@
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Server.Models.IT.SourceCode;
|
||||
using Yavsc.Helpers;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
@ -26,19 +23,19 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (path == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
/*
|
||||
GitRepositoryReference gitRepositoryReference = await _context.GitRepositoryReference.SingleAsync(m => m.Path == path);
|
||||
if (gitRepositoryReference == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
*/
|
||||
var info = Startup.GitOptions.FileProvider.GetFileInfo(path);
|
||||
if (!info.Exists)
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
var stream = info.CreateReadStream();
|
||||
if (path.EndsWith(".ansi.log"))
|
||||
{
|
||||
@ -69,7 +66,7 @@ namespace Yavsc.Controllers
|
||||
GitRepositoryReference gitRepositoryReference = await _context.GitRepositoryReference.SingleAsync(m => m.Id == id);
|
||||
if (gitRepositoryReference == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(gitRepositoryReference);
|
||||
@ -104,7 +101,7 @@ namespace Yavsc.Controllers
|
||||
GitRepositoryReference gitRepositoryReference = await _context.GitRepositoryReference.SingleAsync(m => m.Id == id);
|
||||
if (gitRepositoryReference == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
ViewBag.OwnerId = new SelectList(_context.ApplicationUser, "Id", "Owner", gitRepositoryReference.OwnerId);
|
||||
return View(gitRepositoryReference);
|
||||
@ -131,13 +128,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
GitRepositoryReference gitRepositoryReference = await _context.GitRepositoryReference.SingleAsync(m => m.Path == id);
|
||||
if (gitRepositoryReference == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(gitRepositoryReference);
|
||||
|
@ -1,16 +1,14 @@
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Server.Models.IT;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Yavsc.Server.Helpers;
|
||||
using Yavsc.Models.Workflow;
|
||||
using Yavsc.Models.Payment;
|
||||
using Yavsc.Server.Models.IT.SourceCode;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
@ -43,13 +41,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Project project = await _context.Project.SingleAsync(m => m.Id == id);
|
||||
if (project == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(project);
|
||||
@ -103,13 +101,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Project project = await _context.Project.SingleAsync(m => m.Id == id);
|
||||
if (project == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
/* ViewBag.ClientId = new SelectList(_context.ApplicationUser, "Id", "Client", project.ClientId);
|
||||
ViewBag.ActivityCodeItems = new SelectList(_context.Activities, "Code", "Context", project.ActivityCode);
|
||||
@ -142,13 +140,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Project project = await _context.Project.SingleAsync(m => m.Id == id);
|
||||
if (project == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(project);
|
||||
|
@ -1,10 +1,7 @@
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Musical;
|
||||
|
||||
@ -22,7 +19,7 @@ namespace Yavsc.Controllers
|
||||
// GET: InstrumentRating
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
var applicationDbContext =
|
||||
_context.InstrumentRating
|
||||
.Include(i => i.Profile)
|
||||
@ -37,15 +34,15 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
|
||||
InstrumentRating instrumentRating = await _context.InstrumentRating
|
||||
.Include(i => i.Instrument).SingleAsync(m => m.Id == id);
|
||||
if (instrumentRating == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(instrumentRating);
|
||||
@ -54,7 +51,7 @@ namespace Yavsc.Controllers
|
||||
// GET: InstrumentRating/Create
|
||||
public async Task<IActionResult> Create()
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
|
||||
var actual = await _context.InstrumentRating
|
||||
.Where(m => m.OwnerId == uid). Select( r => r.InstrumentId ).ToArrayAsync();
|
||||
@ -88,13 +85,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
InstrumentRating instrumentRating = await _context.InstrumentRating.SingleAsync(m => m.Id == id);
|
||||
if (instrumentRating == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
ViewData["OwnerId"] = new SelectList(_context.Performers, "PerformerId", "Profile", instrumentRating.OwnerId);
|
||||
return View(instrumentRating);
|
||||
@ -121,14 +118,14 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
InstrumentRating instrumentRating = await _context.InstrumentRating
|
||||
.Include(i => i.Instrument).SingleAsync(m => m.Id == id);
|
||||
if (instrumentRating == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(instrumentRating);
|
||||
|
@ -1,10 +1,9 @@
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Musical.Profiles;
|
||||
|
||||
@ -31,13 +30,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Instrumentation musicianSettings = await _context.Instrumentation.SingleAsync(m => m.UserId == id);
|
||||
if (musicianSettings == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(musicianSettings);
|
||||
@ -46,7 +45,7 @@ namespace Yavsc.Controllers
|
||||
// GET: Instrumentation/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
var owned = _context.Instrumentation.Include(i=>i.Tool).Where(i=>i.UserId==uid).Select(i=>i.InstrumentId);
|
||||
var ownedArray = owned.ToArray();
|
||||
|
||||
@ -61,7 +60,7 @@ namespace Yavsc.Controllers
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Create(Instrumentation model)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
if (model.UserId != uid) if (!User.IsInRole(Constants.AdminGroupName))
|
||||
@ -77,17 +76,17 @@ namespace Yavsc.Controllers
|
||||
// GET: Instrumentation/Edit/5
|
||||
public async Task<IActionResult> Edit(string id)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
if (id != uid) if (!User.IsInRole(Constants.AdminGroupName))
|
||||
return new ChallengeResult();
|
||||
Instrumentation musicianSettings = await _context.Instrumentation.SingleAsync(m => m.UserId == id);
|
||||
if (musicianSettings == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
return View(musicianSettings);
|
||||
}
|
||||
@ -97,7 +96,7 @@ namespace Yavsc.Controllers
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Edit(Instrumentation musicianSettings)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (musicianSettings.UserId != uid) if (!User.IsInRole(Constants.AdminGroupName))
|
||||
return new ChallengeResult();
|
||||
if (ModelState.IsValid)
|
||||
@ -115,15 +114,15 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Instrumentation musicianSettings = await _context.Instrumentation.SingleAsync(m => m.UserId == id);
|
||||
if (musicianSettings == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (musicianSettings.UserId != uid) if (!User.IsInRole(Constants.AdminGroupName))
|
||||
return new ChallengeResult();
|
||||
return View(musicianSettings);
|
||||
@ -136,7 +135,7 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
Instrumentation musicianSettings = await _context.Instrumentation.SingleAsync(m => m.UserId == id);
|
||||
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (musicianSettings.UserId != uid) if (!User.IsInRole(Constants.AdminGroupName))
|
||||
return new ChallengeResult();
|
||||
|
||||
|
@ -1,11 +1,13 @@
|
||||
using System.Linq;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
using System.Security.Claims;
|
||||
using Models;
|
||||
using Models.Musical;
|
||||
using Yavsc.Helpers;
|
||||
|
||||
public class InstrumentsController : Controller
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
@ -26,13 +28,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Instrument instrument = _context.Instrument.Single(m => m.Id == id);
|
||||
if (instrument == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(instrument);
|
||||
@ -63,13 +65,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Instrument instrument = _context.Instrument.Single(m => m.Id == id);
|
||||
if (instrument == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
return View(instrument);
|
||||
}
|
||||
@ -94,13 +96,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Instrument instrument = _context.Instrument.Single(m => m.Id == id);
|
||||
if (instrument == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(instrument);
|
||||
|
@ -1,15 +1,12 @@
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.IT.Fixing;
|
||||
using Yavsc.Models.IT.Evolution;
|
||||
using Yavsc.Server.Helpers;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
@ -40,13 +37,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Bug bug = await _context.Bug.SingleAsync(m => m.Id == id);
|
||||
if (bug == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(bug);
|
||||
@ -89,13 +86,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Bug bug = await _context.Bug.SingleAsync(m => m.Id == id);
|
||||
if (bug == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
ViewBag.Features = Features(_context);
|
||||
@ -126,13 +123,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Bug bug = await _context.Bug.SingleAsync(m => m.Id == id);
|
||||
if (bug == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(bug);
|
||||
@ -156,7 +153,7 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
Bug bugref = await _context.Bug.SingleAsync(m => m.Id == id);
|
||||
if (bugref == null)
|
||||
|
@ -1,12 +1,9 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Models;
|
||||
using Models.IT.Evolution;
|
||||
@ -36,13 +33,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Feature feature = await _context.Feature.SingleAsync(m => m.Id == id);
|
||||
if (feature == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(feature);
|
||||
@ -75,13 +72,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Feature feature = await _context.Feature.SingleAsync(m => m.Id == id);
|
||||
if (feature == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
var featureStatusEnumType = typeof(FeatureStatus);
|
||||
var fsstatuses = new List<SelectListItem>();
|
||||
@ -113,13 +110,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Feature feature = await _context.Feature.SingleAsync(m => m.Id == id);
|
||||
if (feature == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(feature);
|
||||
|
@ -1,4 +1,4 @@
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
@ -13,4 +13,4 @@ namespace Yavsc.Controllers
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user