17 Commits

175 changed files with 1548 additions and 991 deletions

View File

@ -35,3 +35,10 @@ indent_style = space
indent_size = 2 indent_size = 2
dotnet_naming_rule.locals_should_be_camel_case.severity = none
dotnet_naming_rule.locals_should_be_camel_case.symbols = locals_and_parameters
dotnet_naming_rule.locals_should_be_camel_case.style = camel_case_style
dotnet_naming_symbols.locals_and_parameters.applicable_kinds = parameter, local
dotnet_naming_style.camel_case_style.capitalization = camel_case

View File

@ -6,11 +6,11 @@ sudo: false
install: install:
- curl --insecure -sSL https://lua.pschneider.fr/files/Paul/pub/dnx-install.sh | bash - curl --insecure -sSL https://lua.pschneider.fr/files/Paul/pub/dnx-install.sh | bash
- DNX_USER_HOME=`pwd -P`/dnx . ./dnx/dnvm/dnvm.sh - DNX_USER_HOME=`pwd -P`/dnx . ./dnx/dnvm/dnvm.sh
- cd src/OAuth.AspNet.Token && dnu restore - cd src/OAuth.AspNet.Token && dnu restore --ignore-failed-sources
- cd ../OAuth.AspNet.AuthServer && dnu restore - cd ../OAuth.AspNet.AuthServer && dnu restore --ignore-failed-sources
- cd ../Yavsc.Abstract && dnu restore - cd ../Yavsc.Abstract && dnu restore --ignore-failed-sources
- cd ../Yavsc.Server && dnu restore - cd ../Yavsc.Server && dnu restore --ignore-failed-sources
- cd ../Yavsc && dnu restore - cd ../Yavsc && dnu restore --ignore-failed-sources
script: script:
- "dnu build" - "dnu build"

View File

@ -7,12 +7,18 @@ CONFIG=Debug
git_status := $(shell git status -s --porcelain |wc -l) git_status := $(shell git status -s --porcelain |wc -l)
all: yavscd
clean: clean:
rm -f src/Yavsc.Abstract/bin/$(CONFIG)/dnx451/Yavsc.Abstract.dll src/OAuth.AspNet.Token/bin/$(CONFIG)/dnx451/OAuth.AspNet.Token.dll src/OAuth.AspNet.AuthServer/bin/$(CONFIG)/dnx451/OAuth.AspNet.AuthServer.dll src/Yavsc.Server/bin/$(CONFIG)/dnx451/Yavsc.Server.dll src/Yavsc/bin/$(CONFIG)/dnx451/Yavsc.dll rm -f src/Yavsc.Abstract/bin/$(CONFIG)/dnx451/Yavsc.Abstract.dll src/OAuth.AspNet.Token/bin/$(CONFIG)/dnx451/OAuth.AspNet.Token.dll src/OAuth.AspNet.AuthServer/bin/$(CONFIG)/dnx451/OAuth.AspNet.AuthServer.dll src/Yavsc.Server/bin/$(CONFIG)/dnx451/Yavsc.Server.dll src/Yavsc/bin/$(CONFIG)/dnx451/Yavsc.dll
checklibs: checklibs:
ls $(DNXLIBFP) ls $(DNXLIBFP)
updatedeps:
cp src/Yavsc/bin/output/approot/packages/*/*/lib/*net451*/*.dll private/lib/
cp src/Yavsc/bin/output/approot/packages/*/*/lib/*dnx451*/*.dll private/lib/
test: test:
make -C src/test make -C src/test
@ -55,4 +61,8 @@ yavscd: src/Yavsc/bin/$(CONFIG)/dnx451/Yavsc.dll src/Yavsc.Server/bin/$(CONFIG)/
mkbundle --static $(DNXLIBS) src/Yavsc/bin/$(CONFIG)/dnx451/Yavsc.dll src/Yavsc/bin/$(CONFIG)/dnx451/pt/Yavsc.resources.dll src/Yavsc/bin/$(CONFIG)/dnx451/en/Yavsc.resources.dll src/Yavsc.Server/bin/$(CONFIG)/dnx451/Yavsc.Server.dll src/Yavsc.Server/bin/$(CONFIG)/dnx451/en/Yavsc.Server.resources.dll src/Yavsc.Abstract/bin/$(CONFIG)/dnx451/Yavsc.Abstract.dll src/Yavsc.Abstract/bin/$(CONFIG)/dnx451/en/Yavsc.Abstract.resources.dll src/Yavsc.Abstract/bin/$(CONFIG)/dnx451/pt/Yavsc.Abstract.resources.dll src/OAuth.AspNet.AuthServer/bin/$(CONFIG)/dnx451/OAuth.AspNet.AuthServer.dll src/OAuth.AspNet.Token/bin/$(CONFIG)/dnx451/OAuth.AspNet.Token.dll $(LIBS) -L $(DNX_USER_HOME)/runtimes/dnx-mono.1.0.0-rc1-update2/bin --machine-config $(MONO_PREFIX)/etc/mono/4.5/machine.config -o yavscd mkbundle --static $(DNXLIBS) src/Yavsc/bin/$(CONFIG)/dnx451/Yavsc.dll src/Yavsc/bin/$(CONFIG)/dnx451/pt/Yavsc.resources.dll src/Yavsc/bin/$(CONFIG)/dnx451/en/Yavsc.resources.dll src/Yavsc.Server/bin/$(CONFIG)/dnx451/Yavsc.Server.dll src/Yavsc.Server/bin/$(CONFIG)/dnx451/en/Yavsc.Server.resources.dll src/Yavsc.Abstract/bin/$(CONFIG)/dnx451/Yavsc.Abstract.dll src/Yavsc.Abstract/bin/$(CONFIG)/dnx451/en/Yavsc.Abstract.resources.dll src/Yavsc.Abstract/bin/$(CONFIG)/dnx451/pt/Yavsc.Abstract.resources.dll src/OAuth.AspNet.AuthServer/bin/$(CONFIG)/dnx451/OAuth.AspNet.AuthServer.dll src/OAuth.AspNet.Token/bin/$(CONFIG)/dnx451/OAuth.AspNet.Token.dll $(LIBS) -L $(DNX_USER_HOME)/runtimes/dnx-mono.1.0.0-rc1-update2/bin --machine-config $(MONO_PREFIX)/etc/mono/4.5/machine.config -o yavscd
strip yavscd strip yavscd
version-increment-patch:
scripts/version.sh $$(cat version.txt) patch > version.txt
.PHONY: packages .PHONY: packages

44
scripts/version.sh Executable file
View File

@ -0,0 +1,44 @@
#!/bin/bash
version="$1"
major=0
minor=0
build=0
# break down the version number into it's components
regex="([0-9]+).([0-9]+).([0-9]+)((-[A-Za-z]+)([0-9]+))?"
if [[ $version =~ $regex ]]; then
major="${BASH_REMATCH[1]}"
minor="${BASH_REMATCH[2]}"
build="${BASH_REMATCH[3]}"
patchtype="${BASH_REMATCH[5]}"
patchnum="${BASH_REMATCH[6]}"
fi
# check paramater to see which number to increment
if [[ "$2" == "feature" ]]; then
minor=$(echo $minor + 1 | bc)
build=0
patchtype=
patchnum=
elif [[ "$2" == "build" ]]; then
build=$(echo $build + 1 | bc)
patchtype=
patchnum=
elif [[ "$2" == "major" ]]; then
major=$(echo $major+1 | bc)
minor=0
build=0
patchtype=
patchnum=
elif [[ "$2" == "patch" ]]; then
patchnum=$(echo $patchnum + 1 | bc)
else
echo "usage: ./version.sh version_number [major/feature/build/patch]" >&2
exit -1
fi
# echo the new version number
echo "${major}.${minor}.${build}${patchtype}${patchnum}"

View File

@ -33,7 +33,7 @@ namespace OAuth.AspNet.AuthServer
MemoryStream stream, memoryStream = null; MemoryStream stream, memoryStream = null;
StreamWriter streamWriter = null; StreamWriter streamWriter;
try try
{ {

View File

@ -26,7 +26,7 @@
"defaultNamespace": "Yavsc" "defaultNamespace": "Yavsc"
}, },
"dependencies": { "dependencies": {
"Newtonsoft.Json": "6.0.1-beta1", "Newtonsoft.Json": "7.0.1",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-*", "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-*",
"OAuth.AspNet.Token": { "OAuth.AspNet.Token": {
"type": "build", "type": "build",

View File

@ -27,7 +27,7 @@ namespace OAuth.AspNet.Tokens
#region non-Public Members #region non-Public Members
private TicketDataFormat _ticketDataFormat; private readonly TicketDataFormat _ticketDataFormat;
private const string _serializationRegex = @"^[A-Za-z0-9-_]*$"; private const string _serializationRegex = @"^[A-Za-z0-9-_]*$";

View File

@ -26,7 +26,7 @@
"defaultNamespace": "Yavsc" "defaultNamespace": "Yavsc"
}, },
"dependencies": { "dependencies": {
"Newtonsoft.Json": "6.0.1-beta1", "Newtonsoft.Json": "7.0.1",
"Microsoft.AspNet.Authentication.JwtBearer": "1.0.0-rc1-final", "Microsoft.AspNet.Authentication.JwtBearer": "1.0.0-rc1-final",
"Microsoft.AspNet.DataProtection": "1.0.0-rc1-final" "Microsoft.AspNet.DataProtection": "1.0.0-rc1-final"
}, },

View File

@ -5,7 +5,7 @@ namespace Yavsc.Attributes.Validation
public partial class YaStringLength: YaValidationAttribute public partial class YaStringLength: YaValidationAttribute
{ {
public long MinimumLength { get; set; } = 0; public long MinimumLength { get; set; } = 0;
private long maxLen; private readonly long maxLen;
public YaStringLength(long maxLen) : base( ()=> "BadStringLength") public YaStringLength(long maxLen) : base( ()=> "BadStringLength")
{ {
this.maxLen = maxLen; this.maxLen = maxLen;

View File

@ -16,15 +16,15 @@ namespace Yavsc.Authentication
{ {
} }
string clientId;
string clientSecret;
string scope;
Uri authorizeUrl;
Uri accessTokenUrl;
Uri redirectUrl;
GetUsernameAsyncFunc getUsernameAsync;
string requestState; readonly string clientId;
readonly string clientSecret;
readonly string scope;
readonly Uri authorizeUrl;
readonly Uri accessTokenUrl;
readonly Uri redirectUrl;
readonly GetUsernameAsyncFunc getUsernameAsync;
readonly string requestState;
bool reportedForgery = false; bool reportedForgery = false;
/// <summary> /// <summary>

View File

@ -48,7 +48,7 @@ namespace Yavsc
public const string YavscConnectionStringEnvName = "YAVSC_DB_CONNECTION"; public const string YavscConnectionStringEnvName = "YAVSC_DB_CONNECTION";
// at the end, let 4*4 bytes in peace // at the end, let 4*4 bytes in peace
public const int WebSocketsMaxBufLen = 4 * 1020; public const int WebSocketsMaxBufLen = 4096;
public static readonly long DefaultFSQ = 1024 * 1024 * 500; public static readonly long DefaultFSQ = 1024 * 1024 * 500;
@ -60,5 +60,7 @@ namespace Yavsc
public const int MaxUserNameLength = 26; public const int MaxUserNameLength = 26;
public const string LivePath = "/live/cast"; public const string LivePath = "/live/cast";
public const string StreamingPath = "/api/stream/put";
} }
} }

View File

@ -38,6 +38,17 @@ namespace Yavsc.Helpers
return !name.Any(c => !ValidFileNameChars.Contains(c)); return !name.Any(c => !ValidFileNameChars.Contains(c));
} }
public static bool IsValidShortFileName(this string name)
{
if (name.Any(c => !ValidFileNameChars.Contains(c)))
return false;
if (!name.Any(c => !AlfaNum.Contains(c)))
return false;
return true;
}
// Ensure this path is canonical, // Ensure this path is canonical,
// No "dirto/./this", neither "dirt/to/that/" // No "dirto/./this", neither "dirt/to/that/"
// no .. and each char must be listed as valid in constants // no .. and each char must be listed as valid in constants
@ -49,9 +60,9 @@ namespace Yavsc.Helpers
{ {
if (ValidFileNameChars.Contains(c)) if (ValidFileNameChars.Contains(c))
sb.Append(c); sb.Append(c);
else sb.Append("#"+((int)c).ToString("D3")); else sb.Append("#" + ((int)c).ToString("D3"));
} }
return sb.ToString(); return sb.ToString();
} }
public static UserDirectoryInfo GetUserFiles(string userName, string subdir) public static UserDirectoryInfo GetUserFiles(string userName, string subdir)
@ -69,12 +80,13 @@ namespace Yavsc.Helpers
// Server side only supports POSIX file systems // Server side only supports POSIX file systems
public const char RemoteDirectorySeparator = '/'; public const char RemoteDirectorySeparator = '/';
public static char[] AlfaNum = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".ToCharArray();
// Only accept descent remote file names // Only accept descent remote file names
public static char[] ValidFileNameChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-=_~. %#".ToCharArray(); public static char[] ValidFileNameChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-=_~. %#".ToCharArray();
// Estimate signature file name format // Estimate signature file name format
public static Func<string,string,long,string> public static Func<string, string, long, string>
SignFileNameFormat = new Func<string,string,long,string> ((signType,billingCode,estimateId) => $"sign-{billingCode}-{signType}-{estimateId}.png"); SignFileNameFormat = new Func<string, string, long, string>((signType, billingCode, estimateId) => $"sign-{billingCode}-{signType}-{estimateId}.png");
} }
} }

View File

@ -2,7 +2,6 @@ namespace Yavsc.Abstract.FileSystem
{ {
public interface IFileRecievedInfo public interface IFileRecievedInfo
{ {
string MimeType { get; set; }
string DestDir { get; set; } string DestDir { get; set; }

View File

@ -16,7 +16,7 @@ namespace Yavsc.ViewModels.UserFiles
public DirectoryShortInfo [] SubDirectories {  public DirectoryShortInfo [] SubDirectories { 
get; set; get; set;
} }
private DirectoryInfo dInfo; private readonly DirectoryInfo dInfo;
// for deserialization // for deserialization
public UserDirectoryInfo() public UserDirectoryInfo()

View File

@ -3,7 +3,7 @@ namespace Yavsc.Models.Process
{ {
public class Negation<Exp> : IRequisition where Exp : IRequisition public class Negation<Exp> : IRequisition where Exp : IRequisition
{ {
Exp _expression; readonly Exp _expression;
public Negation(Exp expression) public Negation(Exp expression)
{ {
_expression = expression; _expression = expression;

View File

@ -24,11 +24,14 @@
"Chat" "Chat"
] ]
}, },
"buildOptions": {
"nowarn": ["IDE1006"]
},
"tooling": { "tooling": {
"defaultNamespace": "Yavsc" "defaultNamespace": "Yavsc"
}, },
"dependencies": { "dependencies": {
"Newtonsoft.Json": "6.0.1-beta1" "Newtonsoft.Json": "7.0.1"
}, },
"frameworks": { "frameworks": {
"dnx451": { "dnx451": {

View File

@ -31,7 +31,7 @@ namespace Yavsc.Server.Helpers
/// </summary> /// </summary>
public class SimpleJsonPostMethod : IDisposable public class SimpleJsonPostMethod : IDisposable
{ {
private HttpWebRequest request=null; private readonly HttpWebRequest request=null;
/// <summary> /// <summary>
/// Initializes a new instance of the Yavsc.Helpers.SimpleJsonPostMethod class. /// Initializes a new instance of the Yavsc.Helpers.SimpleJsonPostMethod class.

View File

@ -31,7 +31,7 @@ namespace Yavsc.Services
/// I calendar manager. /// I calendar manager.
/// </summary> /// </summary>
public interface ICalendarManager { public interface ICalendarManager {
Task<CalendarList> GetCalendarsAsync (string userId, string pageToken); Task<CalendarList> GetCalendarsAsync (string pageToken);
Task<Events> GetCalendarAsync (string calid, DateTime minDate, DateTime maxDate, string pageToken); Task<Events> GetCalendarAsync (string calid, DateTime minDate, DateTime maxDate, string pageToken);
Task<DateTimeChooserViewModel> CreateViewModelAsync( Task<DateTimeChooserViewModel> CreateViewModelAsync(
string inputId, string inputId,

View File

@ -1,3 +1,4 @@
using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using Newtonsoft.Json; using Newtonsoft.Json;
@ -8,6 +9,7 @@ using Yavsc.Models.Relationship;
namespace Yavsc.Server.Models.Access namespace Yavsc.Server.Models.Access
{ {
[Obsolete]
public class CircleAuthorizationToFile : ICircleAuthorization public class CircleAuthorizationToFile : ICircleAuthorization
{ {

View File

@ -30,10 +30,9 @@ namespace Yavsc.Models.FileSystem
public FileRecievedInfo() public FileRecievedInfo()
{ {
QuotaOffensed = Overriden = false; QuotaOffensed = Overriden = false;
MimeType = DestDir = FileName = null; DestDir = FileName = null;
} }
public string MimeType { get; set; }
public string DestDir { get; set; } public string DestDir { get; set; }
public string FileName { get; set; } public string FileName { get; set; }
public bool Overriden { get; set; } public bool Overriden { get; set; }

View File

@ -34,19 +34,19 @@ namespace Yavsc.Models.HairCut
public string Sender { get; set; } public string Sender { get; set; }
HairCutQuery query; readonly HairCutQuery query;
private string invoiceId; private readonly string invoiceId;
private string payerName; private readonly string payerName;
private string phone; private readonly string phone;
private string payerEmail; private readonly string payerEmail;
private string amount; private readonly string amount;
private HairCutGenders gender; private readonly HairCutGenders gender;
private string date; private readonly string date;
private string lieu; private readonly string lieu;
private string clientFinal; private readonly string clientFinal;
private string token; private readonly string token;
private string payerId; private readonly string payerId;
public string CreateBody() public string CreateBody()
{ {

View File

@ -140,7 +140,7 @@ Prestation.Gender == HairCutGenders.Women ?
bill.Add(new CommandLine bill.Add(new CommandLine
{ {
Name = name, Name = name,
Description = name = name + shorthairsuffix, Description = name + shorthairsuffix,
UnitaryCost = multicolor ? SelectedProfile.ShortMultiColorPrice : SelectedProfile.ShortColorPrice UnitaryCost = multicolor ? SelectedProfile.ShortMultiColorPrice : SelectedProfile.ShortColorPrice
}); });

View File

@ -36,6 +36,5 @@ namespace Yavsc.Models.Haircut
private set; private set;
} }
HairCutQuery Data { get; set; }
} }
} }

View File

@ -39,7 +39,7 @@ namespace Yavsc.Server.Models.IT
[ForeignKey("GitId")] [ForeignKey("GitId")]
public virtual GitRepositoryReference Repository { get; set; } public virtual GitRepositoryReference Repository { get; set; }
List<IBillItem> bill = new List<IBillItem>(); readonly List<IBillItem> bill = new List<IBillItem>();
public void AddBillItem(IBillItem item) public void AddBillItem(IBillItem item)
{ {
bill.Add(item); bill.Add(item);

View File

@ -47,7 +47,7 @@ namespace Yavsc.Server.Models.IT.SourceCode
writer.WriteLine(process.StandardOutput.ReadLine()); writer.WriteLine(process.StandardOutput.ReadLine());
} }
} }
if (ResultHandler!=null) ResultHandler(true); ResultHandler?.Invoke(true);
} }
} }
} }

View File

@ -36,7 +36,7 @@ namespace Yavsc.Server.Models.IT.SourceCode
writer.WriteLine(process.StandardOutput.ReadLine()); writer.WriteLine(process.StandardOutput.ReadLine());
} }
} }
if (ResultHandler!=null) ResultHandler(true); ResultHandler?.Invoke(true);
} }
} }

View File

@ -21,7 +21,7 @@ public class Announce : BaseEvent, IAnnounce, IOwned
public string Message { get; set; } public string Message { get; set; }
public override string CreateBody() public override string CreateBody()
{ {
return $"Annonce de {Owner.UserName}: {For.ToString()}\n\n{Message}"; return $"Annonce de {Owner.UserName}: {For}\n\n{Message}";
} }
} }
} }

View File

@ -24,13 +24,14 @@ namespace Yavsc.Models.Messaging
Sender = perfer.Performer.UserName; Sender = perfer.Performer.UserName;
_localizer = SR; _localizer = SR;
} }
// TODO via e-mail only: Message = string.Format(
// SR["EstimationMessageToClient"],perfer.Performer.UserName, estimate.Title,estimate.Bill.Addition()); // TODO via e-mail only: Message = string.Format(
// // SR["EstimationMessageToClient"],perfer.Performer.UserName, estimate.Title,estimate.Bill.Addition());
ProviderClientInfo ProviderInfo { get; set; } ProviderClientInfo ProviderInfo { get; set; }
Estimate Estimation { get; set; } Estimate Estimation { get; set; }
private PerformerProfile perfer; private readonly PerformerProfile perfer;
public string Topic public string Topic
{ {
@ -46,7 +47,7 @@ namespace Yavsc.Models.Messaging
public string CreateBody() public string CreateBody()
{ {
return string.Format( _localizer["EstimationMessageToClient"], perfer.Performer.UserName, this.Estimation.Bill.Addition()); return string.Format(_localizer["EstimationMessageToClient"], perfer.Performer.UserName, this.Estimation.Bill.Addition());
} }
} }
} }

View File

@ -65,5 +65,17 @@ namespace Yavsc
/// <returns>the supported activity code</returns> /// <returns>the supported activity code</returns>
public string OnlyOneActivityCode { get; set; } public string OnlyOneActivityCode { get; set; }
/// <summary>
/// Disk usage user list maximum length in memory
/// </summary>
/// <value></value>
public int DUUserListLen { get; set; } = 256;
/// <summary>
/// Default acl file name
/// </summary>
/// <value></value>
public string AccessListFileName { get; set; } = ".access";
} }
} }

View File

@ -41,7 +41,8 @@
"Resources/**/*.resx" "Resources/**/*.resx"
], ],
"publicSign": false, "publicSign": false,
"keyFile": "../../../sgKey.snk" "keyFile": "../../../sgKey.snk",
"nowarn": ["IDE1006"]
}, },
"tooling": { "tooling": {
"defaultNamespace": "Yavsc" "defaultNamespace": "Yavsc"

View File

@ -16,7 +16,7 @@ namespace Yavsc.Controllers
public class BlogApiController : Controller public class BlogApiController : Controller
{ {
private ApplicationDbContext _context; private readonly ApplicationDbContext _context;
public BlogApiController(ApplicationDbContext context) public BlogApiController(ApplicationDbContext context)
{ {

View File

@ -12,7 +12,7 @@ namespace Yavsc.Controllers
[Route("api/blogtags")] [Route("api/blogtags")]
public class BlogTagsApiController : Controller public class BlogTagsApiController : Controller
{ {
private ApplicationDbContext _context; private readonly ApplicationDbContext _context;
public BlogTagsApiController(ApplicationDbContext context) public BlogTagsApiController(ApplicationDbContext context)
{ {

View File

@ -14,7 +14,7 @@ namespace Yavsc.Controllers
[Route("api/blogcomments")] [Route("api/blogcomments")]
public class CommentsApiController : Controller public class CommentsApiController : Controller
{ {
private ApplicationDbContext _context; private readonly ApplicationDbContext _context;
public CommentsApiController(ApplicationDbContext context) public CommentsApiController(ApplicationDbContext context)
{ {

View File

@ -20,9 +20,9 @@ namespace Yavsc.ApiControllers
[Authorize,Route("api/fs")] [Authorize,Route("api/fs")]
public partial class FileSystemApiController : Controller public partial class FileSystemApiController : Controller
{ {
ApplicationDbContext dbContext; readonly ApplicationDbContext dbContext;
private IAuthorizationService AuthorizationService; private readonly IAuthorizationService AuthorizationService;
private ILogger _logger; private readonly ILogger _logger;
public FileSystemApiController(ApplicationDbContext context, public FileSystemApiController(ApplicationDbContext context,
IAuthorizationService authorizationService, IAuthorizationService authorizationService,
@ -180,6 +180,8 @@ namespace Yavsc.ApiControllers
} }
return Ok(new { deleted=id }); return Ok(new { deleted=id });
} }
} }
} }

View File

@ -0,0 +1,72 @@
using System.IO;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.AspNet.Authorization;
using Microsoft.AspNet.Mvc;
using Microsoft.Data.Entity;
using Microsoft.Extensions.Logging;
using Yavsc.Attributes.Validation;
using Yavsc.Helpers;
using Yavsc.Models;
using Yavsc.Models.Messaging;
using Yavsc.Services;
namespace Yavsc.ApiControllers
{
[Authorize, Route("api/stream")]
public partial class FileSystemStreamController : Controller
{
private readonly ILogger logger;
private readonly ILiveProcessor liveProcessor;
readonly ApplicationDbContext dbContext;
public FileSystemStreamController(ApplicationDbContext context, ILiveProcessor liveProcessor, ILoggerFactory loggerFactory)
{
this.dbContext = context;
this.logger = loggerFactory.CreateLogger<FileSystemStreamController>();
this.liveProcessor = liveProcessor;
}
[Authorize, Route("put/{filename}")]
public async Task<IActionResult> Put([ValidRemoteUserFilePath] string filename)
{
logger.LogInformation("Put : " + filename);
if (!HttpContext.WebSockets.IsWebSocketRequest)
return HttpBadRequest("not a web socket");
if (!HttpContext.User.Identity.IsAuthenticated)
return new HttpUnauthorizedResult();
var subdirs = filename.Split('/');
var filePath = subdirs.Length > 1 ? string.Join("/", subdirs.Take(subdirs.Length-1)) : null;
var shortFileName = subdirs[subdirs.Length-1];
if (!shortFileName.IsValidShortFileName())
{
logger.LogInformation("invalid file name : " + filename);
return HttpBadRequest("invalid file name");
}
logger.LogInformation("validated: api/stream/Put: "+filename);
var userName = User.GetUserName();
var hubContext = Microsoft.AspNet.SignalR.GlobalHost.ConnectionManager.GetHubContext<ChatHub>();
string url = string.Format(
"{0}/{1}/{2}",
Startup.UserFilesOptions.RequestPath.ToUriComponent(),
userName,
filename
);
hubContext.Clients.All.addPublicStream(new PublicStreamInfo
{
sender = userName,
url = url,
}, $"{userName} is starting a stream!");
string destDir = HttpContext.User.InitPostToFileSystem(filePath);
logger.LogInformation($"Saving flow to {destDir}");
var userId = User.GetUserId();
var user = await dbContext.Users.FirstAsync(u => u.Id == userId);
logger.LogInformation("Accepting stream ...");
await liveProcessor.AcceptStream(HttpContext, user, destDir, shortFileName);
return Ok();
}
}
}

View File

@ -25,15 +25,15 @@ namespace Yavsc.ApiControllers
[Route("api/bill"), Authorize] [Route("api/bill"), Authorize]
public class BillingController : Controller public class BillingController : Controller
{ {
ApplicationDbContext dbContext; readonly ApplicationDbContext dbContext;
private IStringLocalizer _localizer; private readonly IStringLocalizer _localizer;
private GoogleAuthSettings _googleSettings; private readonly GoogleAuthSettings _googleSettings;
private IYavscMessageSender _GCMSender; private readonly IYavscMessageSender _GCMSender;
private IAuthorizationService authorizationService; private readonly IAuthorizationService authorizationService;
private ILogger logger; private readonly ILogger logger;
private IBillingService billingService; private readonly IBillingService billingService;
public BillingController( public BillingController(
IAuthorizationService authorizationService, IAuthorizationService authorizationService,

View File

@ -13,11 +13,11 @@ using Yavsc.Models.Billing;
namespace Yavsc.Controllers namespace Yavsc.Controllers
{ {
[Produces("application/json")] [Produces("application/json")]
[Route("api/estimate"),Authorize()] [Route("api/estimate"), Authorize()]
public class EstimateApiController : Controller public class EstimateApiController : Controller
{ {
private ApplicationDbContext _context; private readonly ApplicationDbContext _context;
private ILogger _logger; private readonly ILogger _logger;
public EstimateApiController(ApplicationDbContext context, ILoggerFactory loggerFactory) public EstimateApiController(ApplicationDbContext context, ILoggerFactory loggerFactory)
{ {
_context = context; _context = context;
@ -28,21 +28,21 @@ namespace Yavsc.Controllers
if (User.IsInRole(Constants.AdminGroupName)) return true; if (User.IsInRole(Constants.AdminGroupName)) return true;
return uid == User.GetUserId(); return uid == User.GetUserId();
} }
bool UserIsAdminOrInThese (string oid, string uid) bool UserIsAdminOrInThese(string oid, string uid)
{ {
if (User.IsInRole(Constants.AdminGroupName)) return true; if (User.IsInRole(Constants.AdminGroupName)) return true;
var cuid = User.GetUserId(); var cuid = User.GetUserId();
return cuid == uid || cuid == oid; return cuid == uid || cuid == oid;
} }
// GET: api/Estimate{?ownerId=User.GetUserId()} // GET: api/Estimate{?ownerId=User.GetUserId()}
[HttpGet] [HttpGet]
public IActionResult GetEstimates(string ownerId=null) public IActionResult GetEstimates(string ownerId = null)
{ {
if ( ownerId == null ) ownerId = User.GetUserId(); if (ownerId == null) ownerId = User.GetUserId();
else if (!UserIsAdminOrThis(ownerId)) // throw new Exception("Not authorized") ; else if (!UserIsAdminOrThis(ownerId)) // throw new Exception("Not authorized") ;
// or just do nothing // or just do nothing
return new HttpStatusCodeResult(StatusCodes.Status403Forbidden); return new HttpStatusCodeResult(StatusCodes.Status403Forbidden);
return Ok(_context.Estimates.Include(e=>e.Bill).Where(e=>e.OwnerId == ownerId)); return Ok(_context.Estimates.Include(e => e.Bill).Where(e => e.OwnerId == ownerId));
} }
// GET: api/Estimate/5 // GET: api/Estimate/5
[HttpGet("{id}", Name = "GetEstimate")] [HttpGet("{id}", Name = "GetEstimate")]
@ -53,20 +53,20 @@ namespace Yavsc.Controllers
return HttpBadRequest(ModelState); return HttpBadRequest(ModelState);
} }
Estimate estimate = _context.Estimates.Include(e=>e.Bill).Single(m => m.Id == id); Estimate estimate = _context.Estimates.Include(e => e.Bill).Single(m => m.Id == id);
if (estimate == null) if (estimate == null)
{ {
return HttpNotFound(); return HttpNotFound();
} }
if (UserIsAdminOrInThese(estimate.ClientId,estimate.OwnerId)) if (UserIsAdminOrInThese(estimate.ClientId, estimate.OwnerId))
return Ok(estimate); return Ok(estimate);
return new HttpStatusCodeResult(StatusCodes.Status403Forbidden); return new HttpStatusCodeResult(StatusCodes.Status403Forbidden);
} }
// PUT: api/Estimate/5 // PUT: api/Estimate/5
[HttpPut("{id}"),Produces("application/json")] [HttpPut("{id}"), Produces("application/json")]
public IActionResult PutEstimate(long id, [FromBody] Estimate estimate) public IActionResult PutEstimate(long id, [FromBody] Estimate estimate)
{ {
@ -84,7 +84,7 @@ namespace Yavsc.Controllers
{ {
if (uid != estimate.OwnerId) if (uid != estimate.OwnerId)
{ {
ModelState.AddModelError("OwnerId","You can only modify your own estimates"); ModelState.AddModelError("OwnerId", "You can only modify your own estimates");
return HttpBadRequest(ModelState); return HttpBadRequest(ModelState);
} }
} }
@ -106,27 +106,30 @@ namespace Yavsc.Controllers
} }
} }
return Ok( new { Id = estimate.Id }); return Ok(new { estimate.Id });
} }
// POST: api/Estimate // POST: api/Estimate
[HttpPost,Produces("application/json")] [HttpPost, Produces("application/json")]
public IActionResult PostEstimate([FromBody] Estimate estimate) public IActionResult PostEstimate([FromBody] Estimate estimate)
{ {
var uid = User.GetUserId(); var uid = User.GetUserId();
if (estimate.OwnerId==null) estimate.OwnerId = uid; if (estimate.OwnerId == null) estimate.OwnerId = uid;
if (!User.IsInRole(Constants.AdminGroupName)) { if (!User.IsInRole(Constants.AdminGroupName))
{
if (uid != estimate.OwnerId) if (uid != estimate.OwnerId)
{ {
ModelState.AddModelError("OwnerId","You can only create your own estimates"); ModelState.AddModelError("OwnerId", "You can only create your own estimates");
return HttpBadRequest(ModelState); return HttpBadRequest(ModelState);
} }
} }
if (estimate.CommandId!=null) { if (estimate.CommandId != null)
{
var query = _context.RdvQueries.FirstOrDefault(q => q.Id == estimate.CommandId); var query = _context.RdvQueries.FirstOrDefault(q => q.Id == estimate.CommandId);
if (query == null) { if (query == null)
{
return HttpBadRequest(ModelState); return HttpBadRequest(ModelState);
} }
query.ValidationDate = DateTime.Now; query.ValidationDate = DateTime.Now;
@ -136,18 +139,18 @@ namespace Yavsc.Controllers
if (!ModelState.IsValid) if (!ModelState.IsValid)
{ {
_logger.LogError(JsonConvert.SerializeObject(ModelState)); _logger.LogError(JsonConvert.SerializeObject(ModelState));
return Json(ModelState); return Json(ModelState);
} }
_context.Estimates.Add(estimate); _context.Estimates.Add(estimate);
/* _context.AttachRange(estimate.Bill); /* _context.AttachRange(estimate.Bill);
_context.Attach(estimate); _context.Attach(estimate);
_context.Entry(estimate).State = EntityState.Added; _context.Entry(estimate).State = EntityState.Added;
foreach (var line in estimate.Bill) foreach (var line in estimate.Bill)
_context.Entry(line).State = EntityState.Added; _context.Entry(line).State = EntityState.Added;
// foreach (var l in estimate.Bill) _context.Attach<CommandLine>(l); // foreach (var l in estimate.Bill) _context.Attach<CommandLine>(l);
*/ */
try try
{ {
_context.SaveChanges(User.GetUserId()); _context.SaveChanges(User.GetUserId());
@ -163,7 +166,7 @@ namespace Yavsc.Controllers
throw; throw;
} }
} }
return Ok( new { Id = estimate.Id, Bill = estimate.Bill }); return Ok(new { estimate.Id, estimate.Bill });
} }
// DELETE: api/Estimate/5 // DELETE: api/Estimate/5
@ -175,7 +178,7 @@ namespace Yavsc.Controllers
return HttpBadRequest(ModelState); return HttpBadRequest(ModelState);
} }
Estimate estimate = _context.Estimates.Include(e=>e.Bill).Single(m => m.Id == id); Estimate estimate = _context.Estimates.Include(e => e.Bill).Single(m => m.Id == id);
if (estimate == null) if (estimate == null)
{ {
@ -186,7 +189,7 @@ namespace Yavsc.Controllers
{ {
if (uid != estimate.OwnerId) if (uid != estimate.OwnerId)
{ {
ModelState.AddModelError("OwnerId","You can only create your own estimates"); ModelState.AddModelError("OwnerId", "You can only create your own estimates");
return HttpBadRequest(ModelState); return HttpBadRequest(ModelState);
} }
} }
@ -196,7 +199,7 @@ namespace Yavsc.Controllers
return Ok(estimate); return Ok(estimate);
} }
protected override void Dispose (bool disposing) protected override void Dispose(bool disposing)
{ {
if (disposing) if (disposing)
{ {

View File

@ -9,9 +9,10 @@ using Yavsc.ViewModels.FrontOffice;
namespace Yavsc.ApiControllers namespace Yavsc.ApiControllers
{ {
[Route("api/front")] [Route("api/front")]
public class FrontOfficeApiController: Controller public class FrontOfficeApiController : Controller
{ {
ApplicationDbContext dbContext; ApplicationDbContext dbContext;
private IBillingService billing; private IBillingService billing;
public FrontOfficeApiController(ApplicationDbContext context, IBillingService billing) public FrontOfficeApiController(ApplicationDbContext context, IBillingService billing)
@ -20,19 +21,19 @@ namespace Yavsc.ApiControllers
this.billing = billing; this.billing = billing;
} }
[HttpGet("profiles/{actCode}")] [HttpGet("profiles/{actCode}")]
IEnumerable<PerformerProfileViewModel> Profiles (string actCode) IEnumerable<PerformerProfileViewModel> Profiles(string actCode)
{ {
return dbContext.ListPerformers(billing, actCode); return dbContext.ListPerformers(billing, actCode);
} }
[HttpPost("query/reject")] [HttpPost("query/reject")]
public IActionResult RejectQuery (string billingCode, long queryId) public IActionResult RejectQuery(string billingCode, long queryId)
{ {
if (billingCode==null) return HttpBadRequest("billingCode"); if (billingCode == null) return HttpBadRequest("billingCode");
if (queryId==0) return HttpBadRequest("queryId"); if (queryId == 0) return HttpBadRequest("queryId");
var billing = BillingService.GetBillable(dbContext, billingCode, queryId); var billing = BillingService.GetBillable(dbContext, billingCode, queryId);
if (billing==null) return HttpBadRequest(); if (billing == null) return HttpBadRequest();
billing.Rejected = true; billing.Rejected = true;
billing.RejectedAt = DateTime.Now; billing.RejectedAt = DateTime.Now;
dbContext.SaveChanges(); dbContext.SaveChanges();

View File

@ -11,8 +11,8 @@ namespace Yavsc.ApiControllers
[Route("api/payment")] [Route("api/payment")]
public class PaymentApiController : Controller public class PaymentApiController : Controller
{ {
private ApplicationDbContext dbContext; private readonly ApplicationDbContext dbContext;
private SiteSettings siteSettings; private readonly SiteSettings siteSettings;
private readonly ILogger _logger; private readonly ILogger _logger;
public PaymentApiController( public PaymentApiController(
ApplicationDbContext dbContext, ApplicationDbContext dbContext,

View File

@ -16,7 +16,7 @@ namespace Yavsc.Controllers
public class PerformersApiController : Controller public class PerformersApiController : Controller
{ {
ApplicationDbContext dbContext; ApplicationDbContext dbContext;
private IBillingService billing; private readonly IBillingService billing;
public PerformersApiController(ApplicationDbContext context, IBillingService billing) public PerformersApiController(ApplicationDbContext context, IBillingService billing)
{ {

View File

@ -14,7 +14,7 @@ namespace Yavsc.Controllers
[Route("api/ProductApi")] [Route("api/ProductApi")]
public class ProductApiController : Controller public class ProductApiController : Controller
{ {
private ApplicationDbContext _context; private readonly ApplicationDbContext _context;
public ProductApiController(ApplicationDbContext context) public ProductApiController(ApplicationDbContext context)
{ {

View File

@ -15,7 +15,7 @@ namespace Yavsc.Controllers
[Route("api/dimiss")] [Route("api/dimiss")]
public class DimissClicksApiController : Controller public class DimissClicksApiController : Controller
{ {
private ApplicationDbContext _context; private readonly ApplicationDbContext _context;
public DimissClicksApiController(ApplicationDbContext context) public DimissClicksApiController(ApplicationDbContext context)
{ {

View File

@ -16,7 +16,7 @@ namespace Yavsc.Controllers
[Authorize] [Authorize]
public class FileCircleApiController : Controller public class FileCircleApiController : Controller
{ {
private ApplicationDbContext _context; private readonly ApplicationDbContext _context;
public FileCircleApiController(ApplicationDbContext context) public FileCircleApiController(ApplicationDbContext context)
{ {

View File

@ -14,7 +14,7 @@ namespace Yavsc.Controllers
[Route("api/bursherprofiles")] [Route("api/bursherprofiles")]
public class BursherProfilesApiController : Controller public class BursherProfilesApiController : Controller
{ {
private ApplicationDbContext _context; private readonly ApplicationDbContext _context;
public BursherProfilesApiController(ApplicationDbContext context) public BursherProfilesApiController(ApplicationDbContext context)
{ {

View File

@ -26,37 +26,12 @@ namespace Yavsc.ApiControllers
[Route("api/haircut")] [Route("api/haircut")]
public class HairCutController : Controller public class HairCutController : Controller
{ {
private ApplicationDbContext _context; private readonly ApplicationDbContext _context;
private IEmailSender _emailSender; private readonly ILogger _logger;
private IYavscMessageSender _GCMSender;
private GoogleAuthSettings _googleSettings;
private IStringLocalizer<YavscLocalisation> _localizer;
private ILogger _logger;
private SiteSettings _siteSettings;
private SmtpSettings _smtpSettings;
private UserManager<ApplicationUser> _userManager;
PayPalSettings _paymentSettings;
public HairCutController(ApplicationDbContext context, public HairCutController(ApplicationDbContext context,
IOptions<GoogleAuthSettings> googleSettings,
IYavscMessageSender GCMSender,
UserManager<ApplicationUser> userManager,
IStringLocalizer<Yavsc.YavscLocalisation> localizer,
IEmailSender emailSender,
IOptions<SmtpSettings> smtpSettings,
IOptions<SiteSettings> siteSettings,
IOptions<PayPalSettings> payPalSettings,
ILoggerFactory loggerFactory) ILoggerFactory loggerFactory)
{ {
_context = context; _context = context;
_GCMSender = GCMSender;
_emailSender = emailSender;
_googleSettings = googleSettings.Value;
_userManager = userManager;
_smtpSettings = smtpSettings.Value;
_siteSettings = siteSettings.Value;
_paymentSettings = payPalSettings.Value;
_localizer = localizer;
_logger = loggerFactory.CreateLogger<HairCutController>(); _logger = loggerFactory.CreateLogger<HairCutController>();
} }

View File

@ -1,11 +1,11 @@
namespace Yavsc.ApiControllers namespace Yavsc.ApiControllers
{ {
using Models; using Models;
using Models.Musical.Profiles; using Yavsc.Models.Musical.Profiles;
public class DjProfileApiController : ProfileApiController<DjSettings> public class DjProfileApiController : ProfileApiController<DjSettings>
{ {
public DjProfileApiController(ApplicationDbContext context) : base(context) public DjProfileApiController() : base()
{ {
} }
} }

View File

@ -13,7 +13,7 @@ namespace Yavsc.Controllers
[Route("api/museprefs")] [Route("api/museprefs")]
public class MusicalPreferencesApiController : Controller public class MusicalPreferencesApiController : Controller
{ {
private ApplicationDbContext _context; private readonly ApplicationDbContext _context;
public MusicalPreferencesApiController(ApplicationDbContext context) public MusicalPreferencesApiController(ApplicationDbContext context)
{ {

View File

@ -13,7 +13,7 @@ namespace Yavsc.Controllers
[Route("api/MusicalTendenciesApi")] [Route("api/MusicalTendenciesApi")]
public class MusicalTendenciesApiController : Controller public class MusicalTendenciesApiController : Controller
{ {
private ApplicationDbContext _context; private readonly ApplicationDbContext _context;
public MusicalTendenciesApiController(ApplicationDbContext context) public MusicalTendenciesApiController(ApplicationDbContext context)
{ {

View File

@ -11,8 +11,8 @@ using Yavsc.Models.Identity;
[Authorize, Route("~/api/gcm")] [Authorize, Route("~/api/gcm")]
public class NativeConfidentialController : Controller public class NativeConfidentialController : Controller
{ {
ILogger _logger; readonly ILogger _logger;
ApplicationDbContext _context; readonly ApplicationDbContext _context;
public NativeConfidentialController(ApplicationDbContext context, public NativeConfidentialController(ApplicationDbContext context,
ILoggerFactory loggerFactory) ILoggerFactory loggerFactory)

View File

@ -10,7 +10,7 @@ namespace Yavsc.Controllers
[Route("~/api/PostRateApi")] [Route("~/api/PostRateApi")]
public class PostRateApiController : Controller public class PostRateApiController : Controller
{ {
private ApplicationDbContext _context; private readonly ApplicationDbContext _context;
public PostRateApiController(ApplicationDbContext context) public PostRateApiController(ApplicationDbContext context)
{ {

View File

@ -9,11 +9,8 @@ namespace Yavsc.ApiControllers
/// </summary> /// </summary>
[Produces("application/json"),Route("api/profile")] [Produces("application/json"),Route("api/profile")]
public abstract class ProfileApiController<T> : Controller public abstract class ProfileApiController<T> : Controller
{ { public ProfileApiController()
ApplicationDbContext dbContext;
public ProfileApiController(ApplicationDbContext context)
{ {
dbContext = context;
} }
} }

View File

@ -14,7 +14,7 @@ namespace Yavsc.Controllers
[Route("api/blacklist"), Authorize] [Route("api/blacklist"), Authorize]
public class BlackListApiController : Controller public class BlackListApiController : Controller
{ {
private ApplicationDbContext _context; private readonly ApplicationDbContext _context;
public BlackListApiController(ApplicationDbContext context) public BlackListApiController(ApplicationDbContext context)
{ {

View File

@ -14,7 +14,7 @@ namespace Yavsc.Controllers
[Route("api/blogacl")] [Route("api/blogacl")]
public class BlogAclApiController : Controller public class BlogAclApiController : Controller
{ {
private ApplicationDbContext _context; private readonly ApplicationDbContext _context;
public BlogAclApiController(ApplicationDbContext context) public BlogAclApiController(ApplicationDbContext context)
{ {

View File

@ -15,9 +15,9 @@ namespace Yavsc.Controllers
[Route("api/chat")] [Route("api/chat")]
public class ChatApiController : Controller public class ChatApiController : Controller
{ {
ApplicationDbContext dbContext; readonly ApplicationDbContext dbContext;
UserManager<ApplicationUser> userManager; readonly UserManager<ApplicationUser> userManager;
private IConnexionManager _cxManager; private readonly IConnexionManager _cxManager;
public ChatApiController(ApplicationDbContext dbContext, public ChatApiController(ApplicationDbContext dbContext,
UserManager<ApplicationUser> userManager, UserManager<ApplicationUser> userManager,
IConnexionManager cxManager) IConnexionManager cxManager)

View File

@ -15,7 +15,7 @@ namespace Yavsc.Controllers
[Route("api/ChatRoomAccessApi")] [Route("api/ChatRoomAccessApi")]
public class ChatRoomAccessApiController : Controller public class ChatRoomAccessApiController : Controller
{ {
private ApplicationDbContext _context; private readonly ApplicationDbContext _context;
public ChatRoomAccessApiController(ApplicationDbContext context) public ChatRoomAccessApiController(ApplicationDbContext context)
{ {

View File

@ -14,7 +14,7 @@ namespace Yavsc.Controllers
[Route("api/ChatRoomApi")] [Route("api/ChatRoomApi")]
public class ChatRoomApiController : Controller public class ChatRoomApiController : Controller
{ {
private ApplicationDbContext _context; private readonly ApplicationDbContext _context;
public ChatRoomApiController(ApplicationDbContext context) public ChatRoomApiController(ApplicationDbContext context)
{ {

View File

@ -14,7 +14,7 @@ namespace Yavsc.Controllers
[Route("api/cirle")] [Route("api/cirle")]
public class CircleApiController : Controller public class CircleApiController : Controller
{ {
private ApplicationDbContext _context; private readonly ApplicationDbContext _context;
public CircleApiController(ApplicationDbContext context) public CircleApiController(ApplicationDbContext context)
{ {

View File

@ -12,7 +12,7 @@ namespace Yavsc.Controllers
[Route("api/ContactsApi")] [Route("api/ContactsApi")]
public class ContactsApiController : Controller public class ContactsApiController : Controller
{ {
private ApplicationDbContext _context; private readonly ApplicationDbContext _context;
public ContactsApiController(ApplicationDbContext context) public ContactsApiController(ApplicationDbContext context)
{ {

View File

@ -14,7 +14,7 @@ namespace Yavsc.Controllers
[Route("api/ServiceApi")] [Route("api/ServiceApi")]
public class ServiceApiController : Controller public class ServiceApiController : Controller
{ {
private ApplicationDbContext _context; private readonly ApplicationDbContext _context;
public ServiceApiController(ApplicationDbContext context) public ServiceApiController(ApplicationDbContext context)
{ {

View File

@ -1,4 +1,4 @@
using System.Collections.Concurrent;
using System.Linq; using System.Linq;
using System.Net.WebSockets; using System.Net.WebSockets;
using System.Security.Claims; using System.Security.Claims;
@ -7,21 +7,17 @@ using System.Threading.Tasks;
using Microsoft.AspNet.Http; using Microsoft.AspNet.Http;
using Microsoft.AspNet.Mvc; using Microsoft.AspNet.Mvc;
using Microsoft.Data.Entity; using Microsoft.Data.Entity;
using Microsoft.Extensions.Logging;
using Yavsc.Models; using Yavsc.Models;
using Yavsc.Models.Streaming; using Yavsc.Models.Streaming;
using Yavsc.Services; using Yavsc.Services;
using Yavsc.ViewModels.Streaming;
namespace Yavsc.Controllers namespace Yavsc.Controllers
{ {
[Route("api/live")] [Route("api/live")]
public class LiveApiController : Controller public class LiveApiController : Controller
{ {
readonly ILiveProcessor _liveProcessor;
ILiveProcessor _liveProcessor; private readonly ApplicationDbContext _dbContext;
private ApplicationDbContext _dbContext;
ILogger _logger;
/// <summary> /// <summary>
/// Live Api Controller /// Live Api Controller
@ -30,13 +26,11 @@ namespace Yavsc.Controllers
/// <param name="context"></param> /// <param name="context"></param>
public LiveApiController( public LiveApiController(
ILoggerFactory loggerFactory,
ApplicationDbContext context, ApplicationDbContext context,
ILiveProcessor liveProcessor) ILiveProcessor liveProcessor)
{ {
_liveProcessor = liveProcessor; _liveProcessor = liveProcessor;
_dbContext = context; _dbContext = context;
_logger = loggerFactory.CreateLogger<LiveApiController>();
} }
[HttpGet("filenamehint/{id}")] [HttpGet("filenamehint/{id}")]

View File

@ -16,8 +16,8 @@ namespace Yavsc.ApiControllers
[Route("~/api/bug")] [Route("~/api/bug")]
public class BugApiController : Controller public class BugApiController : Controller
{ {
private ApplicationDbContext _context; private readonly ApplicationDbContext _context;
ILogger _logger; readonly ILogger _logger;
public BugApiController(ApplicationDbContext context, ILoggerFactory factory) public BugApiController(ApplicationDbContext context, ILoggerFactory factory)
{ {

View File

@ -22,9 +22,8 @@ namespace Yavsc.WebApi.Controllers
private UserManager<ApplicationUser> _userManager; private UserManager<ApplicationUser> _userManager;
private readonly SignInManager<ApplicationUser> _signInManager; private readonly SignInManager<ApplicationUser> _signInManager;
readonly ApplicationDbContext _dbContext;
ApplicationDbContext _dbContext; private readonly ILogger _logger;
private ILogger _logger;
public ApiAccountController(UserManager<ApplicationUser> userManager, public ApiAccountController(UserManager<ApplicationUser> userManager,
SignInManager<ApplicationUser> signInManager, ILoggerFactory loggerFactory, ApplicationDbContext dbContext) SignInManager<ApplicationUser> signInManager, ILoggerFactory loggerFactory, ApplicationDbContext dbContext)

View File

@ -14,7 +14,7 @@ namespace Yavsc.Controllers
[Route("api/users")] [Route("api/users")]
public class ApplicationUserApiController : Controller public class ApplicationUserApiController : Controller
{ {
private ApplicationDbContext _context; private readonly ApplicationDbContext _context;
public ApplicationUserApiController(ApplicationDbContext context) public ApplicationUserApiController(ApplicationDbContext context)
{ {

View File

@ -11,8 +11,8 @@ namespace Yavsc.ApiControllers.accounting
[Route("~/api/profile")] [Route("~/api/profile")]
public class ProfileApiController: Controller public class ProfileApiController: Controller
{ {
UserManager<ApplicationUser> _userManager; readonly UserManager<ApplicationUser> _userManager;
ApplicationDbContext _dbContext; readonly ApplicationDbContext _dbContext;
public ProfileApiController(ApplicationDbContext dbContext, UserManager<ApplicationUser> userManager) public ProfileApiController(ApplicationDbContext dbContext, UserManager<ApplicationUser> userManager)
{ {
_dbContext = dbContext; _dbContext = dbContext;

View File

@ -8,7 +8,7 @@ namespace Yavsc.AuthorizationHandlers
{ {
public class SendMessageHandler : AuthorizationHandler<PrivateChatEntryRequirement, string> public class SendMessageHandler : AuthorizationHandler<PrivateChatEntryRequirement, string>
{ {
ApplicationDbContext _dbContext ; readonly ApplicationDbContext _dbContext ;
public SendMessageHandler(ApplicationDbContext dbContext) public SendMessageHandler(ApplicationDbContext dbContext)
{ {

View File

@ -1,30 +1,37 @@
using Microsoft.AspNet.Authorization; using Microsoft.AspNet.Authorization;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Yavsc.Services; using Yavsc.Services;
using Yavsc.ViewModels.Auth; using Yavsc.ViewModels.Auth;
namespace Yavsc.AuthorizationHandlers { namespace Yavsc.AuthorizationHandlers
{
public class ViewFileHandler : AuthorizationHandler<ViewRequirement, ViewFileContext> { public class ViewFileHandler : AuthorizationHandler<ViewRequirement, ViewFileContext>
{
readonly IFileSystemAuthManager _authManager;
private readonly ILogger _logger;
IFileSystemAuthManager _authManager; public ViewFileHandler(IFileSystemAuthManager authManager, ILoggerFactory logFactory)
{
public ViewFileHandler (IFileSystemAuthManager authManager) {
_authManager = authManager; _authManager = authManager;
_logger = logFactory.CreateLogger<ViewFileHandler>();
} }
protected override void Handle (AuthorizationContext context, ViewRequirement requirement, ViewFileContext fileContext) { protected override void Handle(AuthorizationContext context, ViewRequirement requirement, ViewFileContext fileContext)
// TODO file access rules {
if (fileContext.Path.StartsWith ("/pub/"))
context.Succeed (requirement); var rights = _authManager.GetFilePathAccess(context.User, fileContext.File);
else { _logger.LogInformation("Got access value : " + rights);
if (!fileContext.Path.StartsWith ("/")) if ((rights & FileAccessRight.Read) > 0)
context.Fail (); {
else { _logger.LogInformation("Allowing access");
var rights = _authManager.GetFilePathAccess (context.User, fileContext.Path); context.Succeed(requirement);
if ((rights & FileAccessRight.Read) > 0) }
context.Succeed (requirement); else
else context.Fail (); {
} _logger.LogInformation("Denying access");
context.Fail();
} }
} }
} }

View File

@ -15,7 +15,7 @@ namespace Yavsc.Auth
{ {
internal class GoogleHandler : OAuthHandler<YavscGoogleOptions> internal class GoogleHandler : OAuthHandler<YavscGoogleOptions>
{ {
private ILogger _logger; private readonly ILogger _logger;
public GoogleHandler(HttpClient httpClient,ILogger logger) public GoogleHandler(HttpClient httpClient,ILogger logger)
: base(httpClient) : base(httpClient)
{ {
@ -92,9 +92,11 @@ namespace Yavsc.Auth
{ {
var scope = FormatScope(); var scope = FormatScope();
var queryStrings = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); var queryStrings = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
queryStrings.Add("response_type", "code"); {
queryStrings.Add("client_id", Options.ClientId); { "response_type", "code" },
{ "client_id", Options.ClientId }
};
// this runtime may not known this value, // this runtime may not known this value,
// it should be get from config, // it should be get from config,
// And always be using a secure sheme ... since Google won't support anymore insecure ones. // And always be using a secure sheme ... since Google won't support anymore insecure ones.

View File

@ -16,8 +16,7 @@ namespace Yavsc.Auth
/// </summary> /// </summary>
public class GoogleMiddleware : OAuthMiddleware<YavscGoogleOptions> public class GoogleMiddleware : OAuthMiddleware<YavscGoogleOptions>
{ {
private RequestDelegate _next; private readonly ILogger _logger;
private ILogger _logger;
/// <summary> /// <summary>
/// Initializes a new <see cref="GoogleMiddleware"/>. /// Initializes a new <see cref="GoogleMiddleware"/>.
@ -37,11 +36,6 @@ namespace Yavsc.Auth
YavscGoogleOptions options) YavscGoogleOptions options)
: base(next, dataProtectionProvider, loggerFactory, encoder, sharedOptions, options) : base(next, dataProtectionProvider, loggerFactory, encoder, sharedOptions, options)
{ {
if (next == null)
{
throw new ArgumentNullException(nameof(next));
}
_next = next;
if (dataProtectionProvider == null) if (dataProtectionProvider == null)
{ {

View File

@ -15,8 +15,9 @@ namespace Yavsc.Auth {
_googleUserId = googleUserId; _googleUserId = googleUserId;
Principal = ticket.Principal; Principal = ticket.Principal;
} }
AuthenticationTicket _ticket;
string _googleUserId; readonly AuthenticationTicket _ticket;
readonly string _googleUserId;
public AuthenticationTicket Ticket { get { return _ticket; } } public AuthenticationTicket Ticket { get { return _ticket; } }

View File

@ -12,10 +12,8 @@ namespace Yavsc.Auth
public class MonoJwtSecurityTokenHandler : JwtSecurityTokenHandler public class MonoJwtSecurityTokenHandler : JwtSecurityTokenHandler
{ {
MonoDataProtectionProvider protectionProvider; public MonoJwtSecurityTokenHandler()
public MonoJwtSecurityTokenHandler(MonoDataProtectionProvider prpro)
{ {
protectionProvider = prpro;
} }
public override JwtSecurityToken CreateToken( public override JwtSecurityToken CreateToken(
string issuer, string issuer,

View File

@ -10,11 +10,6 @@ namespace Yavsc.Auth {
public class UserTokenProvider : Microsoft.AspNet.Identity.IUserTokenProvider<ApplicationUser> public class UserTokenProvider : Microsoft.AspNet.Identity.IUserTokenProvider<ApplicationUser>
{ {
private MonoDataProtector protector=null;
public MonoDataProtector Protector {
get { return protector; }
}
public Task<bool> CanGenerateTwoFactorTokenAsync(UserManager<ApplicationUser> manager, ApplicationUser user) public Task<bool> CanGenerateTwoFactorTokenAsync(UserManager<ApplicationUser> manager, ApplicationUser user)
{ {
return Task.FromResult(true); return Task.FromResult(true);

View File

@ -9,7 +9,7 @@ namespace Yavsc.Auth {
public class MonoXmlEncryptor : IXmlEncryptor public class MonoXmlEncryptor : IXmlEncryptor
{ {
public MonoXmlEncryptor (IServiceProvider serviceProvider) public MonoXmlEncryptor ()
{ {
} }
public EncryptedXmlInfo Encrypt(XElement plaintextElement) public EncryptedXmlInfo Encrypt(XElement plaintextElement)

View File

@ -69,9 +69,8 @@ namespace Yavsc.Controllers
[Authorize(Roles = Constants.AdminGroupName)] [Authorize(Roles = Constants.AdminGroupName)]
public IActionResult Index(string page, string len) public IActionResult Index()
{ {
return View(); return View();
} }
@ -262,7 +261,7 @@ namespace Yavsc.Controllers
// For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=532713 // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=532713
// Send an email with this link // Send an email with this link
var code = await _userManager.GenerateEmailConfirmationTokenAsync(user); var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);
var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: "https", host: Startup.Authority); var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code }, protocol: "https", host: Startup.Authority);
var emailSent = await _emailSender.SendEmailAsync(model.UserName, model.Email, _localizer["ConfirmYourAccountTitle"], var emailSent = await _emailSender.SendEmailAsync(model.UserName, model.Email, _localizer["ConfirmYourAccountTitle"],
string.Format(_localizer["ConfirmYourAccountBody"], _siteSettings.Title, callbackUrl, _siteSettings.Slogan, _siteSettings.Audience)); string.Format(_localizer["ConfirmYourAccountBody"], _siteSettings.Title, callbackUrl, _siteSettings.Slogan, _siteSettings.Audience));
// No, wait for more than a login pass submission: // No, wait for more than a login pass submission:
@ -317,7 +316,7 @@ namespace Yavsc.Controllers
{ {
var code = await _userManager.GenerateEmailConfirmationTokenAsync(user); var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);
var callbackUrl = Url.Action("ConfirmEmail", "Account", var callbackUrl = Url.Action("ConfirmEmail", "Account",
new { userId = user.Id, code = code }, protocol: "https", host: Startup.Authority); new { userId = user.Id, code }, protocol: "https", host: Startup.Authority);
var res = await _emailSender.SendEmailAsync(user.UserName, user.Email, var res = await _emailSender.SendEmailAsync(user.UserName, user.Email,
this._localizer["ConfirmYourAccountTitle"], this._localizer["ConfirmYourAccountTitle"],
string.Format(this._localizer["ConfirmYourAccountBody"], string.Format(this._localizer["ConfirmYourAccountBody"],
@ -592,7 +591,7 @@ namespace Yavsc.Controllers
// GET: /Account/ResetPassword // GET: /Account/ResetPassword
[HttpGet] [HttpGet]
[AllowAnonymous] [AllowAnonymous]
public async Task<IActionResult> ResetPassword(string UserId, string code = null) public async Task<IActionResult> ResetPassword(string UserId)
{ {
var user = await _userManager.FindByIdAsync(UserId); var user = await _userManager.FindByIdAsync(UserId);
if (user==null) return new BadRequestResult(); if (user==null) return new BadRequestResult();

View File

@ -29,18 +29,18 @@ namespace Yavsc.Controllers
private readonly SignInManager<ApplicationUser> _signInManager; private readonly SignInManager<ApplicationUser> _signInManager;
private readonly IEmailSender _emailSender; private readonly IEmailSender _emailSender;
private readonly ILogger _logger; private readonly ILogger _logger;
private SiteSettings _siteSettings; private readonly SiteSettings _siteSettings;
private ApplicationDbContext _dbContext; private readonly ApplicationDbContext _dbContext;
private GoogleAuthSettings _googleSettings; private readonly GoogleAuthSettings _googleSettings;
private PayPalSettings _payPalSettings; private readonly PayPalSettings _payPalSettings;
private IYavscMessageSender _GCMSender; private readonly IYavscMessageSender _GCMSender;
private SIRENChecker _cchecker; private readonly SIRENChecker _cchecker;
private IStringLocalizer _SR; private readonly IStringLocalizer _SR;
private CompanyInfoSettings _cinfoSettings; private readonly CompanyInfoSettings _cinfoSettings;
ICalendarManager _calendarManager; readonly ICalendarManager _calendarManager;
public ManageController( public ManageController(
@ -195,9 +195,9 @@ namespace Yavsc.Controllers
// Generate the token and send it // Generate the token and send it
var user = await GetCurrentUserAsync(); var user = await GetCurrentUserAsync();
var code = await _userManager.GenerateChangePhoneNumberTokenAsync(user, model.PhoneNumber); var code = await _userManager.GenerateChangePhoneNumberTokenAsync(user, model.PhoneNumber);
// TODO await _smsSender.SendSmsAsync(_twilioSettings, model.PhoneNumber, "Your security code is: " + code); // TODO ? await _smsSender.SendSmsAsync(_twilioSettings, model.PhoneNumber, "Your security code is: " + code);
return RedirectToAction(nameof(VerifyPhoneNumber), new { PhoneNumber = model.PhoneNumber }); return RedirectToAction(nameof(VerifyPhoneNumber), new { model.PhoneNumber });
} }
// //
@ -300,7 +300,7 @@ namespace Yavsc.Controllers
{ {
var uid = User.GetUserId(); var uid = User.GetUserId();
var calendars = await _calendarManager.GetCalendarsAsync(uid, pageToken); var calendars = await _calendarManager.GetCalendarsAsync(pageToken);
return View(new SetGoogleCalendarViewModel { return View(new SetGoogleCalendarViewModel {
ReturnUrl = returnUrl, ReturnUrl = returnUrl,
Calendars = calendars Calendars = calendars

View File

@ -20,29 +20,14 @@ namespace Yavsc.Controllers
[AllowAnonymous] [AllowAnonymous]
public class OAuthController : Controller public class OAuthController : Controller
{ {
ApplicationDbContext _context; readonly ILogger _logger;
UserManager<ApplicationUser> _userManager;
SiteSettings _siteSettings; public OAuthController(ILoggerFactory loggerFactory)
ILogger _logger;
private readonly SignInManager<ApplicationUser> _signInManager;
public OAuthController(ApplicationDbContext context, SignInManager<ApplicationUser> signInManager, IKeyManager keyManager,
UserManager<ApplicationUser> userManager,
IOptions<SiteSettings> siteSettings,
ILoggerFactory loggerFactory
)
{ {
_siteSettings = siteSettings.Value;
_context = context;
_signInManager = signInManager;
_userManager = userManager;
_logger = loggerFactory.CreateLogger<OAuthController>(); _logger = loggerFactory.CreateLogger<OAuthController>();
} }
[HttpGet("~/api/getclaims"), Produces("application/json")] [HttpGet("~/api/getclaims"), Produces("application/json")]
public IActionResult GetClaims() public IActionResult GetClaims()

View File

@ -10,7 +10,7 @@ namespace Yavsc.Controllers
[Authorize("AdministratorOnly")] [Authorize("AdministratorOnly")]
public class UsersController : Controller public class UsersController : Controller
{ {
private ApplicationDbContext _context; private readonly ApplicationDbContext _context;
public UsersController(ApplicationDbContext context) public UsersController(ApplicationDbContext context)
{ {

View File

@ -16,7 +16,7 @@ namespace Yavsc.Controllers
[Authorize("AdministratorOnly")] [Authorize("AdministratorOnly")]
public class MailingTemplateController : Controller public class MailingTemplateController : Controller
{ {
private ApplicationDbContext _context; private readonly ApplicationDbContext _context;
public MailingTemplateController(ApplicationDbContext context) public MailingTemplateController(ApplicationDbContext context)
{ {

View File

@ -13,10 +13,9 @@ namespace Yavsc.Controllers
{ {
public class AnnouncesController : Controller public class AnnouncesController : Controller
{ {
private ApplicationDbContext _context; private readonly ApplicationDbContext _context;
IStringLocalizer<AnnouncesController> _localizer; readonly IStringLocalizer<AnnouncesController> _localizer;
readonly IAuthorizationService _authorizationService;
IAuthorizationService _authorizationService;
public AnnouncesController(ApplicationDbContext context, public AnnouncesController(ApplicationDbContext context,
IAuthorizationService authorizationService, IAuthorizationService authorizationService,
@ -61,9 +60,7 @@ namespace Yavsc.Controllers
{ {
ViewBag.IsAdmin = User.IsInRole(Constants.AdminGroupName); ViewBag.IsAdmin = User.IsInRole(Constants.AdminGroupName);
ViewBag.IsPerformer = User.IsInRole(Constants.PerformerGroupName); ViewBag.IsPerformer = User.IsInRole(Constants.PerformerGroupName);
ViewBag.AllowEdit = (announce!=null && announce.Id>0) ? ViewBag.AllowEdit = announce==null || announce.Id<=0 || await _authorizationService.AuthorizeAsync(User,announce,new EditRequirement());
await _authorizationService.AuthorizeAsync(User,announce,new EditRequirement()) :
true;
List<SelectListItem> dl = new List<SelectListItem>(); List<SelectListItem> dl = new List<SelectListItem>();
var rnames = System.Enum.GetNames(typeof(Reason)); var rnames = System.Enum.GetNames(typeof(Reason));
var rvalues = System.Enum.GetValues(typeof(Reason)); var rvalues = System.Enum.GetValues(typeof(Reason));

View File

@ -21,11 +21,10 @@ namespace Yavsc.Controllers
{ {
public class BlogspotController : Controller public class BlogspotController : Controller
{ {
ILogger _logger; readonly ILogger _logger;
private ApplicationDbContext _context; private readonly ApplicationDbContext _context;
private IAuthorizationService _authorizationService; private readonly IAuthorizationService _authorizationService;
readonly RequestLocalizationOptions _localisationOptions;
RequestLocalizationOptions _localisationOptions;
public BlogspotController( public BlogspotController(
ApplicationDbContext context, ApplicationDbContext context,
@ -41,7 +40,7 @@ namespace Yavsc.Controllers
// GET: Blog // GET: Blog
[AllowAnonymous] [AllowAnonymous]
public async Task<IActionResult> Index(string id, int skip=0, int maxLen=25) public async Task<IActionResult> Index(string id)
{ {
if (!string.IsNullOrEmpty(id)) { if (!string.IsNullOrEmpty(id)) {
return await UserPosts(id); return await UserPosts(id);

View File

@ -11,7 +11,7 @@ namespace Yavsc.Controllers
{ {
public class CircleController : Controller public class CircleController : Controller
{ {
private ApplicationDbContext _context; private readonly ApplicationDbContext _context;
public CircleController(ApplicationDbContext context) public CircleController(ApplicationDbContext context)
{ {

View File

@ -11,7 +11,7 @@ namespace Yavsc.Controllers
{ {
public class CircleMembersController : Controller public class CircleMembersController : Controller
{ {
private ApplicationDbContext _context; private readonly ApplicationDbContext _context;
public CircleMembersController(ApplicationDbContext context) public CircleMembersController(ApplicationDbContext context)
{ {

View File

@ -13,7 +13,7 @@ namespace Yavsc.Controllers
/// </summary> /// </summary>
public class CommentsController : Controller public class CommentsController : Controller
{ {
private ApplicationDbContext _context; private readonly ApplicationDbContext _context;
public CommentsController(ApplicationDbContext context) public CommentsController(ApplicationDbContext context)
{ {

View File

@ -12,7 +12,7 @@ namespace Yavsc.Controllers
using Models.Identity; using Models.Identity;
public class DevicesController : Controller public class DevicesController : Controller
{ {
private ApplicationDbContext _context; private readonly ApplicationDbContext _context;
public DevicesController(ApplicationDbContext context) public DevicesController(ApplicationDbContext context)
{ {

View File

@ -10,7 +10,7 @@ namespace Yavsc.Controllers
[Authorize("AdministratorOnly")] [Authorize("AdministratorOnly")]
public class HyperLinkController : Controller public class HyperLinkController : Controller
{ {
private ApplicationDbContext _context; private readonly ApplicationDbContext _context;
public HyperLinkController(ApplicationDbContext context) public HyperLinkController(ApplicationDbContext context)
{ {

View File

@ -12,7 +12,7 @@ namespace Yavsc.Controllers
{ {
public class LiveFlowController : Controller public class LiveFlowController : Controller
{ {
private ApplicationDbContext _context; private readonly ApplicationDbContext _context;
public LiveFlowController(ApplicationDbContext context) public LiveFlowController(ApplicationDbContext context)
{ {

View File

@ -14,8 +14,8 @@ namespace Yavsc.Controllers
[Authorize()] [Authorize()]
public class MyFSRulesController : Controller public class MyFSRulesController : Controller
{ {
private ApplicationDbContext _context; private readonly ApplicationDbContext _context;
private ILogger _logger; private readonly ILogger _logger;
public MyFSRulesController(ApplicationDbContext context, public MyFSRulesController(ApplicationDbContext context,
ILoggerFactory loggerFactory) ILoggerFactory loggerFactory)

View File

@ -9,7 +9,7 @@ namespace Yavsc.Controllers
{ {
public class NotificationsController : Controller public class NotificationsController : Controller
{ {
private ApplicationDbContext _context; private readonly ApplicationDbContext _context;
public NotificationsController(ApplicationDbContext context) public NotificationsController(ApplicationDbContext context)
{ {

View File

@ -16,9 +16,9 @@ namespace Yavsc.Controllers
[Authorize("AdministratorOnly")] [Authorize("AdministratorOnly")]
public class ActivityController : Controller public class ActivityController : Controller
{ {
private ApplicationDbContext _context; private readonly ApplicationDbContext _context;
IStringLocalizer<Yavsc.YavscLocalisation> SR; readonly IStringLocalizer<Yavsc.YavscLocalisation> SR;
ILogger logger; readonly ILogger logger;
public ActivityController(ApplicationDbContext context, public ActivityController(ApplicationDbContext context,
IStringLocalizer<Yavsc.YavscLocalisation> SR, IStringLocalizer<Yavsc.YavscLocalisation> SR,

View File

@ -12,7 +12,7 @@ namespace Yavsc.Controllers
{ {
public class ClientController : Controller public class ClientController : Controller
{ {
private ApplicationDbContext _context; private readonly ApplicationDbContext _context;
public ClientController(ApplicationDbContext context) public ClientController(ApplicationDbContext context)
{ {

View File

@ -11,7 +11,7 @@ namespace Yavsc.Controllers
{ {
public class CoWorkingController : Controller public class CoWorkingController : Controller
{ {
private ApplicationDbContext _context; private readonly ApplicationDbContext _context;
public CoWorkingController(ApplicationDbContext context) public CoWorkingController(ApplicationDbContext context)
{ {

View File

@ -90,7 +90,7 @@ namespace Yavsc.Controllers
/// <param name="id"></param> /// <param name="id"></param>
/// <returns></returns> /// <returns></returns>
[HttpGet] [HttpGet]
public IActionResult Create(string proId, string activityCode, string billingCode) public IActionResult Create(string proId, string activityCode)
{ {
if (string.IsNullOrWhiteSpace(proId)) if (string.IsNullOrWhiteSpace(proId))
throw new InvalidOperationException( throw new InvalidOperationException(
@ -159,7 +159,7 @@ namespace Yavsc.Controllers
_context.RdvQueries.Add(command, GraphBehavior.IncludeDependents); _context.RdvQueries.Add(command, GraphBehavior.IncludeDependents);
_context.SaveChanges(User.GetUserId()); _context.SaveChanges(User.GetUserId());
var yaev = command.CreateEvent(_localizer, "NewCommand"); var yaev = command.CreateEvent("NewCommand");
MessageWithPayloadResponse nrep = null; MessageWithPayloadResponse nrep = null;

View File

@ -11,7 +11,7 @@ namespace Yavsc.Controllers
{ {
public class CommandFormsController : Controller public class CommandFormsController : Controller
{ {
private ApplicationDbContext _context; private readonly ApplicationDbContext _context;
public CommandFormsController(ApplicationDbContext context) public CommandFormsController(ApplicationDbContext context)
{ {

View File

@ -8,7 +8,7 @@ namespace Yavsc.Controllers
{ {
public class DjSettingsController : Controller public class DjSettingsController : Controller
{ {
private ApplicationDbContext _context; private readonly ApplicationDbContext _context;
public DjSettingsController(ApplicationDbContext context) public DjSettingsController(ApplicationDbContext context)
{ {

View File

@ -17,9 +17,9 @@ namespace Yavsc.Controllers
[Authorize] [Authorize]
public class DoController : Controller public class DoController : Controller
{ {
private ApplicationDbContext dbContext; private readonly ApplicationDbContext dbContext;
ILogger logger; readonly ILogger logger;
IBillingService billing; readonly IBillingService billing;
public DoController( public DoController(
ApplicationDbContext context, ApplicationDbContext context,
IBillingService billing, IBillingService billing,

View File

@ -21,10 +21,9 @@ namespace Yavsc.Controllers
[Authorize] [Authorize]
public class EstimateController : Controller public class EstimateController : Controller
{ {
private ApplicationDbContext _context; private readonly ApplicationDbContext _context;
private SiteSettings _site; private readonly SiteSettings _site;
readonly IAuthorizationService authorizationService;
IAuthorizationService authorizationService;
public EstimateController(ApplicationDbContext context, IAuthorizationService authorizationService, IOptions<SiteSettings> siteSettings) public EstimateController(ApplicationDbContext context, IAuthorizationService authorizationService, IOptions<SiteSettings> siteSettings)
{ {
@ -143,10 +142,6 @@ namespace Yavsc.Controllers
} }
private void Save(ICollection<IFormFile> newGraphics,
ICollection<IFormFile> newFiles) {
}
// GET: Estimate/Edit/5 // GET: Estimate/Edit/5
public IActionResult Edit(long? id) public IActionResult Edit(long? id)
{ {

View File

@ -9,7 +9,7 @@ namespace Yavsc.Controllers
{ {
public class FormsController : Controller public class FormsController : Controller
{ {
private ApplicationDbContext _context; private readonly ApplicationDbContext _context;
public FormsController(ApplicationDbContext context) public FormsController(ApplicationDbContext context)
{ {

View File

@ -18,13 +18,11 @@ namespace Yavsc.Controllers
public class FrontOfficeController : Controller public class FrontOfficeController : Controller
{ {
ApplicationDbContext _context; readonly ApplicationDbContext _context;
UserManager<ApplicationUser> _userManager; readonly UserManager<ApplicationUser> _userManager;
readonly ILogger _logger;
ILogger _logger; readonly IStringLocalizer _SR;
private readonly IBillingService _billing;
IStringLocalizer _SR;
private IBillingService _billing;
public FrontOfficeController(ApplicationDbContext context, public FrontOfficeController(ApplicationDbContext context,
UserManager<ApplicationUser> userManager, UserManager<ApplicationUser> userManager,

View File

@ -8,7 +8,7 @@ namespace Yavsc.Controllers
{ {
public class GeneralSettingsController : Controller public class GeneralSettingsController : Controller
{ {
private ApplicationDbContext _context; private readonly ApplicationDbContext _context;
public GeneralSettingsController(ApplicationDbContext context) public GeneralSettingsController(ApplicationDbContext context)
{ {

View File

@ -8,7 +8,7 @@ namespace Yavsc.Controllers
using Models.Musical; using Models.Musical;
public class MusicalTendenciesController : Controller public class MusicalTendenciesController : Controller
{ {
private ApplicationDbContext _context; private readonly ApplicationDbContext _context;
public MusicalTendenciesController(ApplicationDbContext context) public MusicalTendenciesController(ApplicationDbContext context)
{ {

View File

@ -10,7 +10,7 @@ namespace Yavsc.Controllers
[Authorize(Roles="Administrator")] [Authorize(Roles="Administrator")]
public class SIRENExceptionsController : Controller public class SIRENExceptionsController : Controller
{ {
private ApplicationDbContext _context; private readonly ApplicationDbContext _context;
public SIRENExceptionsController(ApplicationDbContext context) public SIRENExceptionsController(ApplicationDbContext context)
{ {

Some files were not shown because too many files have changed in this diff Show More