files tree made better.

This commit is contained in:
Paul Schneider 2019-01-01 16:28:47 +00:00
commit ccc91bbf19
1630 changed files with 18209 additions and 41860 deletions

View file

@ -0,0 +1,213 @@
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.Extensions.Localization;
using Microsoft.Extensions.Logging;
namespace Yavsc.Controllers
{
using System.Security.Claims;
using Models;
using Models.Workflow;
[Authorize("AdministratorOnly")]
public class ActivityController : Controller
{
private ApplicationDbContext _context;
IStringLocalizer<Yavsc.Resources.YavscLocalisation> SR;
ILogger logger;
public ActivityController(ApplicationDbContext context,
IStringLocalizer<Yavsc.Resources.YavscLocalisation> SR,
ILoggerFactory loggerFactory)
{
_context = context;
this.SR = SR;
logger=loggerFactory.CreateLogger<ActivityController>();
}
// GET: Activity
public IActionResult Index()
{
SetSettingClasseInfo();
return View(_context.Activities.Include(a=>a.Parent).ToList());
}
private void SetSettingClasseInfo(string currentCode = null)
{
var items = Startup.ProfileTypes.Select(
pt => new SelectListItem
{
Text = SR[pt.FullName],
Value = pt.FullName,
Selected = currentCode == pt.FullName
}).ToList();
items.Add(new SelectListItem { Text = SR[Constants.NoneCode], Value = Constants.NoneCode, Selected = currentCode == null});
ViewBag.SettingsClassName = items;
}
private List<SelectListItem> GetEligibleParent(string code)
{
// eligibles are those
// who are not in descendants
//
var acts = _context.Activities.Where(
a => a.Code != code
).Select(a => new SelectListItem
{
Text = a.Name,
Value = a.Code
}).ToList();
var nullItem = new SelectListItem { Text = SR[Constants.NoneCode], Value = Constants.NoneCode };
acts.Add(nullItem);
if (code == null) return acts;
var existing = _context.Activities.Include(a => a.Children).FirstOrDefault(a => a.Code == code);
if (existing == null) return acts;
var pi = acts.FirstOrDefault(i => i.Value == existing.ParentCode);
if (pi!=null) pi.Selected = true;
else nullItem.Selected = true;
RecFilterChild(acts, existing);
return acts;
}
/// <summary>
/// Filters a activity selection list
/// in order to exculde any descendant
/// from the eligible list at the <c>Parent</c> property.
/// WARN! results in a infinite loop when
/// data is corrupted and there is a circularity
/// in the activity hierarchy graph (Parent/Children)
/// </summary>
/// <param name="list"></param>
/// <param name="activity"></param>
private static void RecFilterChild(List<SelectListItem> list, Activity activity)
{
if (activity == null) return;
if (activity.Children == null) return;
if (list.Count == 0) return;
foreach (var child in activity.Children)
{
RecFilterChild(list, child);
var rem = list.FirstOrDefault(i => i.Value == child.Code);
if (rem != null) list.Remove(rem);
}
}
// GET: Activity/Details/5
public IActionResult Details(string id)
{
if (id == null)
{
return HttpNotFound();
}
Activity activity = _context.Activities.Single(m => m.Code == id);
if (activity == null)
{
return HttpNotFound();
}
return View(activity);
}
// GET: Activity/Create
public IActionResult Create()
{
SetSettingClasseInfo();
ViewBag.ParentCode = GetEligibleParent(null);
return View();
}
// POST: Activity/Create
[HttpPost]
[ValidateAntiForgeryToken]
public IActionResult Create(Activity activity)
{
if (activity.ParentCode==Constants.NoneCode)
activity.ParentCode=null;
if (activity.SettingsClassName==Constants.NoneCode)
activity.SettingsClassName=null;
if (ModelState.IsValid)
{
_context.Activities.Add(activity);
_context.SaveChanges(User.GetUserId());
return RedirectToAction("Index");
}
SetSettingClasseInfo();
return View(activity);
}
// GET: Activity/Edit/5
public IActionResult Edit(string id)
{
if (id == null)
{
return HttpNotFound();
}
Activity activity = _context.Activities.Single(m => m.Code == id);
if (activity == null)
{
return HttpNotFound();
}
ViewBag.ParentCode = GetEligibleParent(id);
SetSettingClasseInfo();
return View(activity);
}
// POST: Activity/Edit/5
[HttpPost]
[ValidateAntiForgeryToken]
public IActionResult Edit(Activity activity)
{
if (activity.ParentCode==Constants.NoneCode)
activity.ParentCode=null;
if (activity.SettingsClassName==Constants.NoneCode)
activity.SettingsClassName=null;
if (ModelState.IsValid)
{
_context.Update(activity);
_context.SaveChanges(User.GetUserId());
return RedirectToAction("Index");
}
return View(activity);
}
// GET: Activity/Delete/5
[ActionName("Delete")]
public IActionResult Delete(string id)
{
if (id == null)
{
return HttpNotFound();
}
Activity activity = _context.Activities.Single(m => m.Code == id);
if (activity == null)
{
return HttpNotFound();
}
return View(activity);
}
// POST: Activity/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public IActionResult DeleteConfirmed(string id)
{
Activity activity = _context.Activities.Single(m => m.Code == id);
_context.Activities.Remove(activity);
_context.SaveChanges(User.GetUserId());
return RedirectToAction("Index");
}
}
}

View file

@ -0,0 +1,139 @@
using System;
using System.Threading.Tasks;
using Microsoft.AspNet.Mvc;
using Microsoft.AspNet.Mvc.Rendering;
using Microsoft.Data.Entity;
using System.Collections.Generic;
using Yavsc.Models;
using Yavsc.Models.Auth;
using System.Security.Claims;
namespace Yavsc.Controllers
{
public class ClientController : Controller
{
private ApplicationDbContext _context;
public ClientController(ApplicationDbContext context)
{
_context = context;
}
// GET: Client
public async Task<IActionResult> Index()
{
return View(await _context.Applications.ToListAsync());
}
// GET: Client/Details/5
public async Task<IActionResult> Details(string id)
{
if (id == null)
{
return HttpNotFound();
}
Client client = await _context.Applications.SingleAsync(m => m.Id == id);
if (client == null)
{
return HttpNotFound();
}
return View(client);
}
// GET: Client/Create
public IActionResult Create()
{
SetAppTypesInputValues();
return View();
}
// POST: Client/Create
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create(Client client)
{
if (ModelState.IsValid)
{
client.Id = Guid.NewGuid().ToString();
_context.Applications.Add(client);
await _context.SaveChangesAsync(User.GetUserId());
return RedirectToAction("Index");
}
SetAppTypesInputValues();
return View(client);
}
private void SetAppTypesInputValues()
{
IEnumerable<SelectListItem> types = new SelectListItem[] {
new SelectListItem {
Text = ApplicationTypes.JavaScript.ToString(),
Value = ((int) ApplicationTypes.JavaScript).ToString() },
new SelectListItem {
Text = ApplicationTypes.NativeConfidential.ToString(),
Value = ((int) ApplicationTypes.NativeConfidential).ToString()
}
};
ViewData["Type"] = types;
}
// GET: Client/Edit/5
public async Task<IActionResult> Edit(string id)
{
if (id == null)
{
return HttpNotFound();
}
Client client = await _context.Applications.SingleAsync(m => m.Id == id);
if (client == null)
{
return HttpNotFound();
}
SetAppTypesInputValues();
return View(client);
}
// POST: Client/Edit/5
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(Client client)
{
if (ModelState.IsValid)
{
_context.Update(client);
await _context.SaveChangesAsync(User.GetUserId());
return RedirectToAction("Index");
}
return View(client);
}
// GET: Client/Delete/5
[ActionName("Delete")]
public async Task<IActionResult> Delete(string id)
{
if (id == null)
{
return HttpNotFound();
}
Client client = await _context.Applications.SingleAsync(m => m.Id == id);
if (client == null)
{
return HttpNotFound();
}
return View(client);
}
// POST: Client/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(string id)
{
Client client = await _context.Applications.SingleAsync(m => m.Id == id);
_context.Applications.Remove(client);
await _context.SaveChangesAsync(User.GetUserId());
return RedirectToAction("Index");
}
}
}

View file

@ -0,0 +1,132 @@
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 Yavsc.Models;
using Yavsc.Models.Workflow;
namespace Yavsc.Controllers
{
public class CoWorkingController : Controller
{
private ApplicationDbContext _context;
public CoWorkingController(ApplicationDbContext context)
{
_context = context;
}
// GET: CoWorking
public async Task<IActionResult> Index()
{
var applicationDbContext = _context.WorkflowProviders.Include(c => c.Performer).Include(c => c.WorkingFor);
return View(await applicationDbContext.ToListAsync());
}
// GET: CoWorking/Details/5
public async Task<IActionResult> Details(long? id)
{
if (id == null)
{
return HttpNotFound();
}
CoWorking coWorking = await _context.WorkflowProviders.SingleAsync(m => m.Id == id);
if (coWorking == null)
{
return HttpNotFound();
}
return View(coWorking);
}
// GET: CoWorking/Create
public IActionResult Create()
{
ViewBag.PerformerId = _context.Performers.Select( p=> new SelectListItem { Value = p.PerformerId, Text = p.Performer.UserName});
ViewBag.WorkingForId = new SelectList(_context.Users, "Id", "UserName");
return View();
}
// POST: CoWorking/Create
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create(CoWorking coWorking)
{
if (ModelState.IsValid)
{
_context.WorkflowProviders.Add(coWorking);
await _context.SaveChangesAsync(User.GetUserId());
return RedirectToAction("Index");
}
ViewData["PerformerId"] = new SelectList(_context.Performers, "PerformerId", "Performer", coWorking.PerformerId);
ViewData["WorkingForId"] = new SelectList(_context.Users, "Id", "WorkingFor", coWorking.WorkingForId);
return View(coWorking);
}
// GET: CoWorking/Edit/5
public async Task<IActionResult> Edit(long? id)
{
if (id == null)
{
return HttpNotFound();
}
CoWorking coWorking = await _context.WorkflowProviders.SingleAsync(m => m.Id == id);
if (coWorking == null)
{
return HttpNotFound();
}
ViewData["PerformerId"] = new SelectList(_context.Performers, "PerformerId", "Performer", coWorking.PerformerId);
ViewData["WorkingForId"] = new SelectList(_context.Users, "Id", "WorkingFor", coWorking.WorkingForId);
return View(coWorking);
}
// POST: CoWorking/Edit/5
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(CoWorking coWorking)
{
if (ModelState.IsValid)
{
_context.Update(coWorking);
await _context.SaveChangesAsync(User.GetUserId());
return RedirectToAction("Index");
}
ViewData["PerformerId"] = new SelectList(_context.Performers, "PerformerId", "Performer", coWorking.PerformerId);
ViewData["WorkingForId"] = new SelectList(_context.Users, "Id", "WorkingFor", coWorking.WorkingForId);
return View(coWorking);
}
// GET: CoWorking/Delete/5
[ActionName("Delete")]
public async Task<IActionResult> Delete(long? id)
{
if (id == null)
{
return HttpNotFound();
}
CoWorking coWorking = await _context.WorkflowProviders.SingleAsync(m => m.Id == id);
if (coWorking == null)
{
return HttpNotFound();
}
return View(coWorking);
}
// POST: CoWorking/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(long id)
{
CoWorking coWorking = await _context.WorkflowProviders.SingleAsync(m => m.Id == id);
_context.WorkflowProviders.Remove(coWorking);
await _context.SaveChangesAsync(User.GetUserId());
return RedirectToAction("Index");
}
}
}

View file

@ -0,0 +1,277 @@
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.Extensions.Localization;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.OptionsModel;
namespace Yavsc.Controllers
{
using Helpers;
using Models;
using Models.Google.Messaging;
using Models.Relationship;
using Models.Workflow;
using Services;
public class CommandController : Controller
{
protected UserManager<ApplicationUser> _userManager;
protected ApplicationDbContext _context;
protected GoogleAuthSettings _googleSettings;
protected IGoogleCloudMessageSender _GCMSender;
protected IEmailSender _emailSender;
protected IStringLocalizer _localizer;
protected SiteSettings _siteSettings;
protected SmtpSettings _smtpSettings;
protected ICalendarManager _calendarManager;
protected readonly ILogger _logger;
public CommandController(ApplicationDbContext context, IOptions<GoogleAuthSettings> googleSettings,
IGoogleCloudMessageSender GCMSender,
UserManager<ApplicationUser> userManager,
ICalendarManager calendarManager,
IStringLocalizer<Yavsc.Resources.YavscLocalisation> localizer,
IEmailSender emailSender,
IOptions<SmtpSettings> smtpSettings,
IOptions<SiteSettings> siteSettings,
ILoggerFactory loggerFactory)
{
_context = context;
_GCMSender = GCMSender;
_emailSender = emailSender;
_googleSettings = googleSettings.Value;
_userManager = userManager;
_smtpSettings = smtpSettings.Value;
_siteSettings = siteSettings.Value;
_calendarManager = calendarManager;
_localizer = localizer;
_logger = loggerFactory.CreateLogger<CommandController>();
}
// GET: Command
[Authorize]
public virtual async Task<IActionResult> Index()
{
var uid = User.GetUserId();
return View(await _context.RdvQueries
.Include(x => x.Client)
.Include(x => x.PerformerProfile)
.Include(x => x.PerformerProfile.Performer)
.Include(x => x.Location)
.Where(x=> x.ClientId == uid || x.PerformerId == uid)
.ToListAsync());
}
// GET: Command/Details/5
public virtual async Task<IActionResult> Details(long id)
{
RdvQuery command = await _context.RdvQueries
.Include(x => x.Location)
.Include(x => x.PerformerProfile)
.SingleAsync(m => m.Id == id);
if (command == null)
{
return HttpNotFound();
}
return View(command);
}
/// <summary>
/// Gives a view on
/// Creating a command for a specified performer
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet]
public IActionResult Create(string proId, string activityCode, string billingCode)
{
if (string.IsNullOrWhiteSpace(proId))
throw new InvalidOperationException(
"This method needs a performer id (from parameter proId)"
);
if (string.IsNullOrWhiteSpace(activityCode))
throw new InvalidOperationException(
"This method needs an activity code"
);
var pro = _context.Performers.Include(
x => x.Performer).FirstOrDefault(
x => x.PerformerId == proId
);
if (pro == null)
return HttpNotFound();
ViewBag.Activity = _context.Activities.FirstOrDefault(a=>a.Code == activityCode);
ViewBag.GoogleSettings = _googleSettings;
var userid = User.GetUserId();
var user = _userManager.FindByIdAsync(userid).Result;
return View("Create",new RdvQuery(activityCode,new Location(),DateTime.Now.AddHours(4))
{
PerformerProfile = pro,
PerformerId = pro.PerformerId,
ClientId = userid,
Client = user,
ActivityCode = activityCode
});
}
// POST: Command/Create
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create(RdvQuery command)
{
// TODO validate BillingCode value
var uid = User.GetUserId();
var prid = command.PerformerId;
if (string.IsNullOrWhiteSpace(uid)
|| string.IsNullOrWhiteSpace(prid))
throw new InvalidOperationException(
"This method needs a PerformerId"
);
var pro = _context.Performers.Include(
u => u.Performer
).Include(u => u.Performer.Devices)
.FirstOrDefault(
x => x.PerformerId == command.PerformerId
);
var user = await _userManager.FindByIdAsync(uid);
command.Client = user;
command.ClientId = uid;
command.PerformerProfile = pro;
// FIXME Why!!
// ModelState.ClearValidationState("PerformerProfile.Avatar");
// ModelState.ClearValidationState("Client.Avatar");
// ModelState.ClearValidationState("ClientId");
ModelState.MarkFieldSkipped("ClientId");
if (ModelState.IsValid)
{
var existingLocation = _context.Locations.FirstOrDefault( x=>x.Address == command.Location.Address
&& x.Longitude == command.Location.Longitude && x.Latitude == command.Location.Latitude );
if (existingLocation!=null) {
command.Location=existingLocation;
}
else _context.Attach<Location>(command.Location);
_context.RdvQueries.Add(command, GraphBehavior.IncludeDependents);
_context.SaveChanges(User.GetUserId());
var yaev = command.CreateEvent(_localizer, "NewCommand");
MessageWithPayloadResponse grep = null;
if (pro.AcceptNotifications
&& pro.AcceptPublicContact)
{
try {
if (pro.Performer.Devices.Count > 0) {
var regids = command.PerformerProfile.Performer
.Devices.Select(d => d.GCMRegistrationId);
grep = await _GCMSender.NotifyBookQueryAsync(regids,yaev);
}
_logger.LogError("sending GCM");
// TODO setup a profile choice to allow notifications
// both on mailbox and mobile
// if (grep==null || grep.success<=0 || grep.failure>0)
ViewBag.GooglePayload=grep;
}
catch (Exception ex)
{
_logger.LogError(ex.Message);
}
try {
ViewBag.EmailSent = await _emailSender.SendEmailAsync(
command.PerformerProfile.Performer.UserName,
command.PerformerProfile.Performer.Email,
$"{command.Client.UserName} (un client) vous demande un rendez-vous",
$"{yaev.CreateBody()}\r\n-- \r\n{yaev.Previsional}\r\n{yaev.EventDate}\r\n"
);
}
catch (Exception ex)
{
_logger.LogError(ex.Message);
}
}
ViewBag.Activity = _context.Activities.FirstOrDefault(a=>a.Code == command.ActivityCode);
ViewBag.GoogleSettings = _googleSettings;
return View("CommandConfirmation",command);
}
ViewBag.Activity = _context.Activities.FirstOrDefault(a=>a.Code == command.ActivityCode);
ViewBag.GoogleSettings = _googleSettings;
return View(command);
}
// GET: Command/Edit/5
public IActionResult Edit(long? id)
{
if (id == null)
{
return HttpNotFound();
}
RdvQuery command = _context.RdvQueries.Single(m => m.Id == id);
if (command == null)
{
return HttpNotFound();
}
return View(command);
}
// POST: Command/Edit/5
[HttpPost]
[ValidateAntiForgeryToken]
public IActionResult Edit(RdvQuery command)
{
if (ModelState.IsValid)
{
_context.Update(command);
_context.SaveChanges(User.GetUserId());
return RedirectToAction("Index");
}
return View(command);
}
// GET: Command/Delete/5
[ActionName("Delete")]
public IActionResult Delete(long? id)
{
if (id == null)
{
return HttpNotFound();
}
RdvQuery command = _context.RdvQueries.Single(m => m.Id == id);
if (command == null)
{
return HttpNotFound();
}
return View(command);
}
// POST: Command/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public IActionResult DeleteConfirmed(long id)
{
RdvQuery command = _context.RdvQueries.Single(m => m.Id == id);
_context.RdvQueries.Remove(command);
_context.SaveChanges(User.GetUserId());
return RedirectToAction("Index");
}
public IActionResult CGV()
{
return View();
}
}
}

View file

@ -0,0 +1,131 @@
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 Yavsc.Models;
using Yavsc.Models.Workflow;
namespace Yavsc.Controllers
{
public class CommandFormsController : Controller
{
private ApplicationDbContext _context;
public CommandFormsController(ApplicationDbContext context)
{
_context = context;
}
// GET: CommandForms
public async Task<IActionResult> Index()
{
var applicationDbContext = _context.CommandForm.Include(c => c.Context);
return View(await applicationDbContext.ToListAsync());
}
// GET: CommandForms/Details/5
public async Task<IActionResult> Details(long? id)
{
if (id == null)
{
return HttpNotFound();
}
CommandForm commandForm = await _context.CommandForm.SingleAsync(m => m.Id == id);
if (commandForm == null)
{
return HttpNotFound();
}
return View(commandForm);
}
// GET: CommandForms/Create
public IActionResult Create()
{
SetViewBag();
return View();
}
private void SetViewBag(CommandForm commandForm=null) {
ViewBag.ActivityCode = new SelectList(_context.Activities, "Code", "Name", commandForm?.ActivityCode);
ViewBag.ActionName = Startup.Forms.Select( c => new SelectListItem { Value = c, Text = c, Selected = (commandForm?.ActionName == c) } );
}
// POST: CommandForms/Create
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create(CommandForm commandForm)
{
if (ModelState.IsValid)
{
_context.CommandForm.Add(commandForm);
await _context.SaveChangesAsync(User.GetUserId());
return RedirectToAction("Index");
}
SetViewBag(commandForm);
return View(commandForm);
}
// GET: CommandForms/Edit/5
public async Task<IActionResult> Edit(long? id)
{
if (id == null)
{
return HttpNotFound();
}
CommandForm commandForm = await _context.CommandForm.SingleAsync(m => m.Id == id);
if (commandForm == null)
{
return HttpNotFound();
}
SetViewBag(commandForm);
return View(commandForm);
}
// POST: CommandForms/Edit/5
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(CommandForm commandForm)
{
if (ModelState.IsValid)
{
_context.Update(commandForm);
await _context.SaveChangesAsync(User.GetUserId());
return RedirectToAction("Index");
}
SetViewBag(commandForm);
return View(commandForm);
}
// GET: CommandForms/Delete/5
[ActionName("Delete")]
public async Task<IActionResult> Delete(long? id)
{
if (id == null)
{
return HttpNotFound();
}
CommandForm commandForm = await _context.CommandForm.SingleAsync(m => m.Id == id);
if (commandForm == null)
{
return HttpNotFound();
}
return View(commandForm);
}
// POST: CommandForms/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(long id)
{
CommandForm commandForm = await _context.CommandForm.SingleAsync(m => m.Id == id);
_context.CommandForm.Remove(commandForm);
await _context.SaveChangesAsync(User.GetUserId());
return RedirectToAction("Index");
}
}
}

View file

@ -0,0 +1,120 @@
using System.Threading.Tasks;
using Microsoft.AspNet.Mvc;
using Microsoft.Data.Entity;
using Yavsc.Models;
using Yavsc.Models.Musical.Profiles;
namespace Yavsc.Controllers
{
public class DjSettingsController : Controller
{
private ApplicationDbContext _context;
public DjSettingsController(ApplicationDbContext context)
{
_context = context;
}
// GET: DjSettings
public async Task<IActionResult> Index()
{
return View(await _context.DjSettings.ToListAsync());
}
// GET: DjSettings/Details/5
public async Task<IActionResult> Details(string id)
{
if (id == null)
{
return HttpNotFound();
}
DjSettings djSettings = await _context.DjSettings.SingleAsync(m => m.UserId == id);
if (djSettings == null)
{
return HttpNotFound();
}
return View(djSettings);
}
// GET: DjSettings/Create
public IActionResult Create()
{
return View();
}
// POST: DjSettings/Create
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create(DjSettings djSettings)
{
if (ModelState.IsValid)
{
_context.DjSettings.Add(djSettings);
await _context.SaveChangesAsync();
return RedirectToAction("Index");
}
return View(djSettings);
}
// GET: DjSettings/Edit/5
public async Task<IActionResult> Edit(string id)
{
if (id == null)
{
return HttpNotFound();
}
DjSettings djSettings = await _context.DjSettings.SingleAsync(m => m.UserId == id);
if (djSettings == null)
{
return HttpNotFound();
}
return View(djSettings);
}
// POST: DjSettings/Edit/5
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(DjSettings djSettings)
{
if (ModelState.IsValid)
{
_context.Update(djSettings);
await _context.SaveChangesAsync();
return RedirectToAction("Index");
}
return View(djSettings);
}
// GET: DjSettings/Delete/5
[ActionName("Delete")]
public async Task<IActionResult> Delete(string id)
{
if (id == null)
{
return HttpNotFound();
}
DjSettings djSettings = await _context.DjSettings.SingleAsync(m => m.UserId == id);
if (djSettings == null)
{
return HttpNotFound();
}
return View(djSettings);
}
// POST: DjSettings/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(string id)
{
DjSettings djSettings = await _context.DjSettings.SingleAsync(m => m.UserId == id);
_context.DjSettings.Remove(djSettings);
await _context.SaveChangesAsync();
return RedirectToAction("Index");
}
}
}

View file

@ -0,0 +1,187 @@
using System.Linq;
using System.Security.Claims;
using Microsoft.AspNet.Authorization;
using Microsoft.AspNet.Mvc;
using Microsoft.AspNet.Mvc.Rendering;
using Microsoft.Data.Entity;
namespace Yavsc.Controllers
{
using Microsoft.Extensions.Logging;
using Models;
using Models.Workflow;
using Yavsc.ViewModels.Workflow;
using Yavsc.Services;
using System.Threading.Tasks;
[Authorize]
public class DoController : Controller
{
private ApplicationDbContext dbContext;
ILogger logger;
IBillingService billing;
public DoController(
ApplicationDbContext context,
IBillingService billing,
ILogger<DoController> logger)
{
dbContext = context;
this.billing = billing;
this.logger = logger;
}
// GET: /Do/Index
[HttpGet]
public IActionResult Index(string id)
{
if (id == null)
id = User.GetUserId();
var userActivities = dbContext.UserActivities.Include(u => u.Does)
.Include(u => u.User).Where(u=> u.UserId == id)
.OrderByDescending(u => u.Weight);
return View(userActivities.ToList());
}
// GET: Do/Details/5
public async Task<IActionResult> Details(string id, string activityCode)
{
if (id == null || activityCode == null)
{
return HttpNotFound();
}
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();
}
bool hasConfigurableSettings = (userActivity.Does.SettingsClassName != null);
var settings = await billing.GetPerformerSettingsAsync(activityCode,id);
ViewBag.ProfileType = Startup.ProfileTypes.Single(t=>t.FullName==userActivity.Does.SettingsClassName);
var gift = new UserActivityViewModel {
Declaration = userActivity,
Settings = settings,
NeedsSettings = hasConfigurableSettings
};
return View (gift);
}
// GET: Do/Create
[ActionName("Create"),Authorize]
public IActionResult Create(string userId)
{
if (userId==null)
userId = User.GetUserId();
var model = new UserActivity { UserId = userId };
ViewBag.DoesCode = new SelectList(dbContext.Activities, "Code", "Name");
//ViewData["UserId"] = userId;
ViewBag.UserId = new SelectList(dbContext.Performers.Include(p=>p.Performer), "PerformerId", "Performer", userId);
return View(model);
}
// POST: Do/Create
[HttpPost(),ActionName("Create"),Authorize]
[ValidateAntiForgeryToken]
public IActionResult Create(UserActivity userActivity)
{
var uid = User.GetUserId();
if (!User.IsInRole("Administrator"))
if (uid != userActivity.UserId)
ModelState.AddModelError("User","You're not admin.");
if (userActivity.UserId == null) userActivity.UserId = uid;
if (ModelState.IsValid)
{
dbContext.UserActivities.Add(userActivity);
dbContext.SaveChanges(User.GetUserId());
return RedirectToAction("Index");
}
ViewBag.DoesCode = new SelectList(dbContext.Activities, "Code", "Name", userActivity.DoesCode);
ViewBag.UserId = new SelectList(dbContext.Performers.Include(p=>p.Performer), "PerformerId", "User", userActivity.UserId);
return View(userActivity);
}
// GET: Do/Edit/5
[Authorize]
public IActionResult Edit(string id, string activityCode)
{
if (id == null)
{
return HttpNotFound();
}
UserActivity userActivity = dbContext.UserActivities.Include(
u=>u.Does
).Include(
u=>u.User
).Single(m => m.DoesCode == activityCode && m.UserId == id);
if (userActivity == null)
{
return HttpNotFound();
}
ViewData["DoesCode"] = new SelectList(dbContext.Activities, "Code", "Does", userActivity.DoesCode);
ViewData["UserId"] = new SelectList(dbContext.Performers, "PerformerId", "User", userActivity.UserId);
return View(userActivity);
}
// POST: Do/Edit/5
[HttpPost,Authorize]
[ValidateAntiForgeryToken]
public IActionResult Edit(UserActivity userActivity)
{
if (!User.IsInRole("Administrator"))
if (User.GetUserId() != userActivity.UserId)
ModelState.AddModelError("User","You're not admin.");
if (ModelState.IsValid)
{
dbContext.Update(userActivity);
dbContext.SaveChanges(User.GetUserId());
return RedirectToAction("Index");
}
ViewData["DoesCode"] = new SelectList(dbContext.Activities, "Code", "Does", userActivity.DoesCode);
ViewData["UserId"] = new SelectList(dbContext.Performers, "PerformerId", "User", userActivity.UserId);
return View(userActivity);
}
// GET: Do/Delete/5
[ActionName("Delete"),Authorize]
public IActionResult Delete(string id, string activityCode)
{
if (id == null)
{
return HttpNotFound();
}
UserActivity userActivity = dbContext.UserActivities.Single(m => m.UserId == id && m.DoesCode == activityCode);
if (userActivity == null)
{
return HttpNotFound();
}
if (!User.IsInRole("Administrator"))
if (User.GetUserId() != userActivity.UserId)
ModelState.AddModelError("User","You're not admin.");
return View(userActivity);
}
// POST: Do/Delete/5
[HttpPost, ActionName("Delete"),Authorize]
[ValidateAntiForgeryToken]
public IActionResult DeleteConfirmed(UserActivity userActivity)
{
if (!ModelState.IsValid)
return new BadRequestObjectResult(ModelState);
if (!User.IsInRole("Administrator"))
if (User.GetUserId() != userActivity.UserId) {
ModelState.AddModelError("User","You're not admin.");
return RedirectToAction("Index");
}
dbContext.UserActivities.Remove(userActivity);
dbContext.SaveChanges(User.GetUserId());
return RedirectToAction("Index");
}
}
}

View file

@ -0,0 +1,219 @@
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;
namespace Yavsc.Controllers
{
using Models;
using Models.Billing;
using Models.Workflow;
using ViewModels.Auth;
using Yavsc.Abstract.FileSystem;
[Authorize]
public class EstimateController : Controller
{
private ApplicationDbContext _context;
private SiteSettings _site;
IAuthorizationService authorizationService;
public EstimateController(ApplicationDbContext context, IAuthorizationService authorizationService, IOptions<SiteSettings> siteSettings)
{
_context = context;
_site = siteSettings.Value;
this.authorizationService = authorizationService;
}
// GET: Estimate
public IActionResult Index()
{
var uid = User.GetUserId();
return View(_context.Estimates.Include(e=>e.Query)
.Include(e=>e.Query.PerformerProfile)
.Include(e=>e.Query.PerformerProfile.Performer)
.Where(
e=>e.OwnerId == uid || e.ClientId == uid
).OrderByDescending(e=>e.ProviderValidationDate)
.ToList());
}
// GET: Estimate/Details/5
public async Task<IActionResult> Details(long? id)
{
var uid = User.GetUserId();
if (id == null)
{
return HttpNotFound();
}
Estimate estimate = _context.Estimates
.Include(e => e.Query)
.Include(e => e.Query.PerformerProfile)
.Include(e => e.Query.PerformerProfile.Performer)
.Include(e=> e.Bill)
.Where(
e=>e.OwnerId == uid || e.ClientId == uid
)
.Single(m => m.Id == id);
if (estimate == null)
{
return HttpNotFound();
}
if (!await authorizationService.AuthorizeAsync(User, estimate, new ViewRequirement()))
{
return new ChallengeResult();
}
return View(estimate);
}
// GET: Estimate/Create
[Authorize]
public IActionResult Create()
{
var uid = User.GetUserId();
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();
ViewBag.Queries = queries;
return View();
}
// POST: Estimate/Create
[HttpPost]
[ValidateAntiForgeryToken]
public IActionResult Create(Estimate estimate,
ICollection<IFormFile> newGraphics,
ICollection<IFormFile> newFiles
)
{
estimate.OwnerId = User.GetUserId();
if (ModelState.IsValid)
{
_context.Estimates
.Add(estimate);
_context.SaveChanges(User.GetUserId());
var query = _context.RdvQueries.FirstOrDefault(
q=>q.Id == estimate.CommandId
);
var perfomerProfile = _context.Performers
.Include(
perpr => perpr.Performer).FirstOrDefault(
x=>x.PerformerId == query.PerformerId
);
var command = _context.RdvQueries.FirstOrDefault(
cmd => cmd.Id == estimate.CommandId
);
var billsdir = Path.Combine(
_site.Bills,
perfomerProfile.Performer.UserName
);
foreach (var gr in newGraphics)
{
ContentDisposition contentDisposition = new ContentDisposition(gr.ContentDisposition);
gr.SaveAs(
Path.Combine(
Path.Combine(billsdir, estimate.Id.ToString()),
contentDisposition.FileName));
}
foreach (var formFile in newFiles)
{
ContentDisposition contentDisposition = new ContentDisposition(formFile.ContentDisposition);
formFile.SaveAs(
Path.Combine(
Path.Combine(billsdir, estimate.Id.ToString()),
contentDisposition.FileName));
}
return RedirectToAction("Index");
}
return View(estimate);
}
private void Save(ICollection<IFormFile> newGraphics,
ICollection<IFormFile> newFiles) {
}
// GET: Estimate/Edit/5
public IActionResult Edit(long? id)
{
if (id == null)
{
return HttpNotFound();
}
var uid = User.GetUserId();
Estimate estimate = _context.Estimates
.Where(e=>e.OwnerId==uid||e.ClientId==uid).Single(m => m.Id == id);
if (estimate == null)
{
return HttpNotFound();
}
ViewBag.Files = User.GetUserFiles(null);
return View(estimate);
}
// POST: Estimate/Edit/5
[HttpPost]
[ValidateAntiForgeryToken]
public IActionResult Edit(Estimate estimate)
{
var uid = User.GetUserId();
if (estimate.OwnerId!=uid&&estimate.ClientId!=uid
) return new HttpNotFoundResult();
if (ModelState.IsValid)
{
_context.Update(estimate);
_context.SaveChanges(User.GetUserId());
return RedirectToAction("Index");
}
return View(estimate);
}
// GET: Estimate/Delete/5
[ActionName("Delete")]
public IActionResult Delete(long? id)
{
if (id == null)
{
return HttpNotFound();
}
var uid = User.GetUserId();
Estimate estimate = _context.Estimates
.Where(e=>e.OwnerId==uid||e.ClientId==uid) .Single(m => m.Id == id);
if (estimate == null)
{
return HttpNotFound();
}
return View(estimate);
}
// POST: Estimate/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public IActionResult DeleteConfirmed(long id)
{
Estimate estimate = _context.Estimates.Single(m => m.Id == id);
_context.Estimates.Remove(estimate);
_context.SaveChanges(User.GetUserId());
return RedirectToAction("Index");
}
}
}

View file

@ -0,0 +1,15 @@
using Yavsc.Controllers.Generic;
using Yavsc.Models;
using Yavsc.Models.Workflow.Profiles;
namespace Yavsc.Controllers
{
public class FormationSettingsController : SettingsController<FormationSettings>
{
public FormationSettingsController(ApplicationDbContext context) : base(context)
{
}
}
}

View file

@ -0,0 +1,121 @@
using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.AspNet.Mvc;
using Microsoft.Data.Entity;
using Yavsc.Models;
using Yavsc.Models.Forms;
namespace Yavsc.Controllers
{
public class FormsController : Controller
{
private ApplicationDbContext _context;
public FormsController(ApplicationDbContext context)
{
_context = context;
}
// GET: Forms
public async Task<IActionResult> Index()
{
return View(await _context.Form.ToListAsync());
}
// GET: Forms/Details/5
public async Task<IActionResult> Details(string id)
{
if (id == null)
{
return HttpNotFound();
}
Form form = await _context.Form.SingleAsync(m => m.Id == id);
if (form == null)
{
return HttpNotFound();
}
return View(form);
}
// GET: Forms/Create
public IActionResult Create()
{
return View();
}
// POST: Forms/Create
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create(Form form)
{
if (ModelState.IsValid)
{
_context.Form.Add(form);
await _context.SaveChangesAsync(User.GetUserId());
return RedirectToAction("Index");
}
return View(form);
}
// GET: Forms/Edit/5
public async Task<IActionResult> Edit(string id)
{
if (id == null)
{
return HttpNotFound();
}
Form form = await _context.Form.SingleAsync(m => m.Id == id);
if (form == null)
{
return HttpNotFound();
}
return View(form);
}
// POST: Forms/Edit/5
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(Form form)
{
if (ModelState.IsValid)
{
_context.Update(form);
await _context.SaveChangesAsync(User.GetUserId());
return RedirectToAction("Index");
}
return View(form);
}
// GET: Forms/Delete/5
[ActionName("Delete")]
public async Task<IActionResult> Delete(string id)
{
if (id == null)
{
return HttpNotFound();
}
Form form = await _context.Form.SingleAsync(m => m.Id == id);
if (form == null)
{
return HttpNotFound();
}
return View(form);
}
// POST: Forms/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(string id)
{
Form form = await _context.Form.SingleAsync(m => m.Id == id);
_context.Form.Remove(form);
await _context.SaveChangesAsync(User.GetUserId());
return RedirectToAction("Index");
}
}
}

View file

@ -0,0 +1,139 @@
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 System.Security.Claims;
namespace Yavsc.Controllers
{
using Helpers;
using Microsoft.Extensions.Localization;
using Models;
using ViewModels.FrontOffice;
using Yavsc.Abstract.FileSystem;
using Yavsc.Services;
public class FrontOfficeController : Controller
{
ApplicationDbContext _context;
UserManager<ApplicationUser> _userManager;
ILogger _logger;
IStringLocalizer _SR;
private IBillingService _billing;
public FrontOfficeController(ApplicationDbContext context,
UserManager<ApplicationUser> userManager,
IBillingService billing,
ILoggerFactory loggerFactory,
IStringLocalizer<Yavsc.Resources.YavscLocalisation> SR)
{
_context = context;
_userManager = userManager;
_logger = loggerFactory.CreateLogger<FrontOfficeController>();
_SR = SR;
_billing = billing;
}
public ActionResult Index()
{
var uid = User.GetUserId();
var now = DateTime.Now;
var model = new FrontOfficeIndexViewModel
{
EstimateToProduceCount = _context.RdvQueries.Where(c => c.PerformerId == uid && c.EventDate > now
&& c.ValidationDate == null && !_context.Estimates.Any(e => (e.CommandId == c.Id && e.ProviderValidationDate != null))).Count(),
EstimateToSignAsProCount = _context.RdvQueries.Where(c => (c.PerformerId == uid && c.EventDate > now
&& c.ValidationDate == null && _context.Estimates.Any(e => (e.CommandId == c.Id && e.ProviderValidationDate != null)))).Count(),
EstimateToSignAsCliCount = _context.Estimates.Where(e => e.ClientId == uid && e.ClientValidationDate == null).Count(),
BillToSignAsProCount = 0,
BillToSignAsCliCount = 0,
NewPayementsCount = 0
};
return View(model);
}
[AllowAnonymous]
public ActionResult Profiles(string id)
{
if (id == null)
{
throw new NotImplementedException("No Activity code");
}
ViewBag.Activity = _context.Activities.FirstOrDefault(a => a.Code == id);
var result = _context.ListPerformers(_billing, id);
return View(result);
}
[AllowAnonymous]
public ActionResult HairCut(string id)
{
if (id == null)
{
throw new NotImplementedException("No Activity code");
}
ViewBag.Activity = _context.Activities.FirstOrDefault(a => a.Code == id);
var result = _context.ListPerformers(_billing, id);
return View(result);
}
[Produces("text/x-tex"), Authorize, Route("estimate-{id}.tex")]
public ViewResult EstimateTex(long id)
{
var estimate = _context.Estimates.Include(x => x.Query)
.Include(x => x.Query.Client)
.Include(x => x.Query.PerformerProfile)
.Include(x => x.Query.PerformerProfile.OrganizationAddress)
.Include(x => x.Query.PerformerProfile.Performer)
.Include(e => e.Bill).FirstOrDefault(x => x.Id == id);
Response.ContentType = "text/x-tex";
return View("Estimate.tex", estimate);
}
[Authorize, Route("Estimate-{id}.pdf")]
public IActionResult EstimatePdf(long id)
{
ViewBag.TempDir = Startup.SiteSetup.TempDir;
ViewBag.BillsDir = AbstractFileSystemHelpers.UserBillsDirName;
var estimate = _context.Estimates.Include(x => x.Query)
.Include(x => x.Query.Client)
.Include(x => x.Query.PerformerProfile)
.Include(x => x.Query.PerformerProfile.OrganizationAddress)
.Include(x => x.Query.PerformerProfile.Performer)
.Include(e => e.Bill).FirstOrDefault(x => x.Id == id);
if (estimate == null)
throw new Exception("No data");
return View("Estimate.pdf", estimate);
}
[Authorize]
public IActionResult EstimateProValidation()
{
throw new NotImplementedException();
}
[Authorize]
public IActionResult EstimateClientValidation()
{
throw new NotImplementedException();
}
[Authorize]
public IActionResult BillValidation()
{
throw new NotImplementedException();
}
[Authorize]
public IActionResult BillAcquitment()
{
throw new NotImplementedException();
}
}
}

View file

@ -0,0 +1,120 @@
using System.Threading.Tasks;
using Microsoft.AspNet.Mvc;
using Microsoft.Data.Entity;
using Yavsc.Models;
using Yavsc.Models.Musical.Profiles;
namespace Yavsc.Controllers
{
public class GeneralSettingsController : Controller
{
private ApplicationDbContext _context;
public GeneralSettingsController(ApplicationDbContext context)
{
_context = context;
}
// GET: GeneralSettings
public async Task<IActionResult> Index()
{
return View(await _context.GeneralSettings.ToListAsync());
}
// GET: GeneralSettings/Details/5
public async Task<IActionResult> Details(string id)
{
if (id == null)
{
return HttpNotFound();
}
GeneralSettings generalSettings = await _context.GeneralSettings.SingleAsync(m => m.UserId == id);
if (generalSettings == null)
{
return HttpNotFound();
}
return View(generalSettings);
}
// GET: GeneralSettings/Create
public IActionResult Create()
{
return View();
}
// POST: GeneralSettings/Create
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create(GeneralSettings generalSettings)
{
if (ModelState.IsValid)
{
_context.GeneralSettings.Add(generalSettings);
await _context.SaveChangesAsync();
return RedirectToAction("Index");
}
return View(generalSettings);
}
// GET: GeneralSettings/Edit/5
public async Task<IActionResult> Edit(string id)
{
if (id == null)
{
return HttpNotFound();
}
GeneralSettings generalSettings = await _context.GeneralSettings.SingleAsync(m => m.UserId == id);
if (generalSettings == null)
{
return HttpNotFound();
}
return View(generalSettings);
}
// POST: GeneralSettings/Edit/5
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(GeneralSettings generalSettings)
{
if (ModelState.IsValid)
{
_context.Update(generalSettings);
await _context.SaveChangesAsync();
return RedirectToAction("Index");
}
return View(generalSettings);
}
// GET: GeneralSettings/Delete/5
[ActionName("Delete")]
public async Task<IActionResult> Delete(string id)
{
if (id == null)
{
return HttpNotFound();
}
GeneralSettings generalSettings = await _context.GeneralSettings.SingleAsync(m => m.UserId == id);
if (generalSettings == null)
{
return HttpNotFound();
}
return View(generalSettings);
}
// POST: GeneralSettings/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(string id)
{
GeneralSettings generalSettings = await _context.GeneralSettings.SingleAsync(m => m.UserId == id);
_context.GeneralSettings.Remove(generalSettings);
await _context.SaveChangesAsync();
return RedirectToAction("Index");
}
}
}

View file

@ -0,0 +1,149 @@
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 Yavsc.Models;
using Yavsc.Models.Musical.Profiles;
namespace Yavsc.Controllers
{
[Authorize]
public class InstrumentationController : Controller
{
private ApplicationDbContext _context;
public InstrumentationController(ApplicationDbContext context)
{
_context = context;
}
// GET: Instrumentation
public async Task<IActionResult> Index()
{
return View(await _context.Instrumentation.ToListAsync());
}
// GET: Instrumentation/Details/5
public async Task<IActionResult> Details(string id)
{
if (id == null)
{
return HttpNotFound();
}
Instrumentation musicianSettings = await _context.Instrumentation.SingleAsync(m => m.UserId == id);
if (musicianSettings == null)
{
return HttpNotFound();
}
return View(musicianSettings);
}
// GET: Instrumentation/Create
public IActionResult Create()
{
var uid = User.GetUserId();
var owned = _context.Instrumentation.Include(i=>i.Tool).Where(i=>i.UserId==uid).Select(i=>i.InstrumentId);
var ownedArray = owned.ToArray();
ViewBag.YetAvailableInstruments = _context.Instrument.Select(k=>new SelectListItem
{ Text = k.Name, Value = k.Id.ToString(), Disabled = ownedArray.Contains(k.Id) });
return View(new Instrumentation { UserId = uid });
}
// POST: Instrumentation/Create
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create(Instrumentation model)
{
var uid = User.GetUserId();
if (ModelState.IsValid)
{
if (model.UserId != uid) if (!User.IsInRole(Constants.AdminGroupName))
return new ChallengeResult();
_context.Instrumentation.Add(model);
await _context.SaveChangesAsync(User.GetUserId());
return RedirectToAction("Index");
}
return View(model);
}
// GET: Instrumentation/Edit/5
public async Task<IActionResult> Edit(string id)
{
var uid = User.GetUserId();
if (id == null)
{
return HttpNotFound();
}
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 View(musicianSettings);
}
// POST: Instrumentation/Edit/5
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(Instrumentation musicianSettings)
{
var uid = User.GetUserId();
if (musicianSettings.UserId != uid) if (!User.IsInRole(Constants.AdminGroupName))
return new ChallengeResult();
if (ModelState.IsValid)
{
_context.Update(musicianSettings);
await _context.SaveChangesAsync(User.GetUserId());
return RedirectToAction("Index");
}
return View(musicianSettings);
}
// GET: Instrumentation/Delete/5
[ActionName("Delete")]
public async Task<IActionResult> Delete(string id)
{
if (id == null)
{
return HttpNotFound();
}
Instrumentation musicianSettings = await _context.Instrumentation.SingleAsync(m => m.UserId == id);
if (musicianSettings == null)
{
return HttpNotFound();
}
var uid = User.GetUserId();
if (musicianSettings.UserId != uid) if (!User.IsInRole(Constants.AdminGroupName))
return new ChallengeResult();
return View(musicianSettings);
}
// POST: Instrumentation/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(string id)
{
Instrumentation musicianSettings = await _context.Instrumentation.SingleAsync(m => m.UserId == id);
var uid = User.GetUserId();
if (musicianSettings.UserId != uid) if (!User.IsInRole(Constants.AdminGroupName))
return new ChallengeResult();
_context.Instrumentation.Remove(musicianSettings);
await _context.SaveChangesAsync(User.GetUserId());
return RedirectToAction("Index");
}
}
}

View file

@ -0,0 +1,120 @@
using System.Linq;
using Microsoft.AspNet.Mvc;
namespace Yavsc.Controllers
{
using System.Security.Claims;
using Models;
using Models.Musical;
public class InstrumentsController : Controller
{
private ApplicationDbContext _context;
public InstrumentsController(ApplicationDbContext context)
{
_context = context;
}
// GET: Instruments
public IActionResult Index()
{
return View(_context.Instrument.ToList());
}
// GET: Instruments/Details/5
public IActionResult Details(long? id)
{
if (id == null)
{
return HttpNotFound();
}
Instrument instrument = _context.Instrument.Single(m => m.Id == id);
if (instrument == null)
{
return HttpNotFound();
}
return View(instrument);
}
// GET: Instruments/Create
public IActionResult Create()
{
return View();
}
// POST: Instruments/Create
[HttpPost]
[ValidateAntiForgeryToken]
public IActionResult Create(Instrument instrument)
{
if (ModelState.IsValid)
{
_context.Instrument.Add(instrument);
_context.SaveChanges(User.GetUserId());
return RedirectToAction("Index");
}
return View(instrument);
}
// GET: Instruments/Edit/5
public IActionResult Edit(long? id)
{
if (id == null)
{
return HttpNotFound();
}
Instrument instrument = _context.Instrument.Single(m => m.Id == id);
if (instrument == null)
{
return HttpNotFound();
}
return View(instrument);
}
// POST: Instruments/Edit/5
[HttpPost]
[ValidateAntiForgeryToken]
public IActionResult Edit(Instrument instrument)
{
if (ModelState.IsValid)
{
_context.Update(instrument);
_context.SaveChanges(User.GetUserId());
return RedirectToAction("Index");
}
return View(instrument);
}
// GET: Instruments/Delete/5
[ActionName("Delete")]
public IActionResult Delete(long? id)
{
if (id == null)
{
return HttpNotFound();
}
Instrument instrument = _context.Instrument.Single(m => m.Id == id);
if (instrument == null)
{
return HttpNotFound();
}
return View(instrument);
}
// POST: Instruments/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public IActionResult DeleteConfirmed(long id)
{
Instrument instrument = _context.Instrument.Single(m => m.Id == id);
_context.Instrument.Remove(instrument);
_context.SaveChanges(User.GetUserId());
return RedirectToAction("Index");
}
}
}

View file

@ -0,0 +1,120 @@
using System.Linq;
using Microsoft.AspNet.Mvc;
namespace Yavsc.Controllers
{
using System.Security.Claims;
using Models;
using Models.Musical;
public class MusicalTendenciesController : Controller
{
private ApplicationDbContext _context;
public MusicalTendenciesController(ApplicationDbContext context)
{
_context = context;
}
// GET: MusicalTendencies
public IActionResult Index()
{
return View(_context.MusicalTendency.ToList());
}
// GET: MusicalTendencies/Details/5
public IActionResult Details(long? id)
{
if (id == null)
{
return HttpNotFound();
}
MusicalTendency musicalTendency = _context.MusicalTendency.Single(m => m.Id == id);
if (musicalTendency == null)
{
return HttpNotFound();
}
return View(musicalTendency);
}
// GET: MusicalTendencies/Create
public IActionResult Create()
{
return View();
}
// POST: MusicalTendencies/Create
[HttpPost]
[ValidateAntiForgeryToken]
public IActionResult Create(MusicalTendency musicalTendency)
{
if (ModelState.IsValid)
{
_context.MusicalTendency.Add(musicalTendency);
_context.SaveChanges(User.GetUserId());
return RedirectToAction("Index");
}
return View(musicalTendency);
}
// GET: MusicalTendencies/Edit/5
public IActionResult Edit(long? id)
{
if (id == null)
{
return HttpNotFound();
}
MusicalTendency musicalTendency = _context.MusicalTendency.Single(m => m.Id == id);
if (musicalTendency == null)
{
return HttpNotFound();
}
return View(musicalTendency);
}
// POST: MusicalTendencies/Edit/5
[HttpPost]
[ValidateAntiForgeryToken]
public IActionResult Edit(MusicalTendency musicalTendency)
{
if (ModelState.IsValid)
{
_context.Update(musicalTendency);
_context.SaveChanges(User.GetUserId());
return RedirectToAction("Index");
}
return View(musicalTendency);
}
// GET: MusicalTendencies/Delete/5
[ActionName("Delete")]
public IActionResult Delete(long? id)
{
if (id == null)
{
return HttpNotFound();
}
MusicalTendency musicalTendency = _context.MusicalTendency.Single(m => m.Id == id);
if (musicalTendency == null)
{
return HttpNotFound();
}
return View(musicalTendency);
}
// POST: MusicalTendencies/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public IActionResult DeleteConfirmed(long id)
{
MusicalTendency musicalTendency = _context.MusicalTendency.Single(m => m.Id == id);
_context.MusicalTendency.Remove(musicalTendency);
_context.SaveChanges(User.GetUserId());
return RedirectToAction("Index");
}
}
}

View file

@ -0,0 +1,122 @@
using System.Linq;
using System.Security.Claims;
using Microsoft.AspNet.Authorization;
using Microsoft.AspNet.Mvc;
using Yavsc.Models;
using Yavsc.Models.Billing;
namespace Yavsc.Controllers
{
[Authorize(Roles="Administrator")]
public class SIRENExceptionsController : Controller
{
private ApplicationDbContext _context;
public SIRENExceptionsController(ApplicationDbContext context)
{
_context = context;
}
// GET: SIRENExceptions
public IActionResult Index()
{
return View(_context.ExceptionsSIREN.ToList());
}
// GET: SIRENExceptions/Details/5
public IActionResult Details(string id)
{
if (id == null)
{
return HttpNotFound();
}
ExceptionSIREN exceptionSIREN = _context.ExceptionsSIREN.Single(m => m.SIREN == id);
if (exceptionSIREN == null)
{
return HttpNotFound();
}
return View(exceptionSIREN);
}
// GET: SIRENExceptions/Create
public IActionResult Create()
{
return View();
}
// POST: SIRENExceptions/Create
[HttpPost]
[ValidateAntiForgeryToken]
public IActionResult Create(ExceptionSIREN exceptionSIREN)
{
if (ModelState.IsValid)
{
_context.ExceptionsSIREN.Add(exceptionSIREN);
_context.SaveChanges(User.GetUserId());
return RedirectToAction("Index");
}
return View(exceptionSIREN);
}
// GET: SIRENExceptions/Edit/5
public IActionResult Edit(string id)
{
if (id == null)
{
return HttpNotFound();
}
ExceptionSIREN exceptionSIREN = _context.ExceptionsSIREN.Single(m => m.SIREN == id);
if (exceptionSIREN == null)
{
return HttpNotFound();
}
return View(exceptionSIREN);
}
// POST: SIRENExceptions/Edit/5
[HttpPost]
[ValidateAntiForgeryToken]
public IActionResult Edit(ExceptionSIREN exceptionSIREN)
{
if (ModelState.IsValid)
{
_context.Update(exceptionSIREN);
_context.SaveChanges(User.GetUserId());
return RedirectToAction("Index");
}
return View(exceptionSIREN);
}
// GET: SIRENExceptions/Delete/5
[ActionName("Delete")]
public IActionResult Delete(string id)
{
if (id == null)
{
return HttpNotFound();
}
ExceptionSIREN exceptionSIREN = _context.ExceptionsSIREN.Single(m => m.SIREN == id);
if (exceptionSIREN == null)
{
return HttpNotFound();
}
return View(exceptionSIREN);
}
// POST: SIRENExceptions/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public IActionResult DeleteConfirmed(string id)
{
ExceptionSIREN exceptionSIREN = _context.ExceptionsSIREN.Single(m => m.SIREN == id);
_context.ExceptionsSIREN.Remove(exceptionSIREN);
_context.SaveChanges(User.GetUserId());
return RedirectToAction("Index");
}
}
}