un positionnement de paramètre workflow des pros
This commit is contained in:
parent
fbd352e788
commit
96746fcc0b
322 changed files with 25893 additions and 3844 deletions
|
|
@ -1,24 +1,97 @@
|
|||
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;
|
||||
using Yavsc.Models;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
[ServiceFilter(typeof(LanguageActionFilter)),Authorize("AdministratorOnly")]
|
||||
[Authorize("AdministratorOnly")]
|
||||
public class ActivityController : Controller
|
||||
{
|
||||
private ApplicationDbContext _context;
|
||||
IStringLocalizer<Yavsc.Resources.YavscLocalisation> SR;
|
||||
ILogger logger;
|
||||
|
||||
public ActivityController(ApplicationDbContext context)
|
||||
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()
|
||||
{
|
||||
return View(_context.Activities.ToList());
|
||||
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.Key],
|
||||
Value = pt.Key,
|
||||
Selected = currentCode == pt.Key
|
||||
}).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
|
||||
|
|
@ -41,6 +114,8 @@ namespace Yavsc.Controllers
|
|||
// GET: Activity/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
SetSettingClasseInfo();
|
||||
ViewBag.ParentCode = GetEligibleParent(null);
|
||||
return View();
|
||||
}
|
||||
|
||||
|
|
@ -49,12 +124,18 @@ namespace Yavsc.Controllers
|
|||
[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();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
SetSettingClasseInfo();
|
||||
return View(activity);
|
||||
}
|
||||
|
||||
|
|
@ -71,6 +152,8 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
ViewBag.ParentCode = GetEligibleParent(id);
|
||||
SetSettingClasseInfo();
|
||||
return View(activity);
|
||||
}
|
||||
|
||||
|
|
@ -79,6 +162,10 @@ namespace Yavsc.Controllers
|
|||
[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);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
|
|
@ -7,7 +6,10 @@ using Microsoft.AspNet.Authorization;
|
|||
using Microsoft.AspNet.Identity;
|
||||
using Microsoft.AspNet.Identity.EntityFramework;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Auth;
|
||||
using Yavsc.ViewModels.Administration;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
|
|
@ -17,11 +19,15 @@ namespace Yavsc.Controllers
|
|||
private readonly UserManager<ApplicationUser> _userManager;
|
||||
private readonly RoleManager<IdentityRole> _roleManager;
|
||||
|
||||
private readonly ApplicationDbContext context;
|
||||
|
||||
public AdministrationController(UserManager<ApplicationUser> userManager,
|
||||
RoleManager<IdentityRole> roleManager)
|
||||
RoleManager<IdentityRole> roleManager,
|
||||
ApplicationDbContext context)
|
||||
{
|
||||
_userManager = userManager;
|
||||
_roleManager = roleManager;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -47,30 +53,53 @@ namespace Yavsc.Controllers
|
|||
AddErrors(addToRoleResult);
|
||||
return new BadRequestObjectResult(ModelState);
|
||||
}
|
||||
return Ok(new {message="you owned it."});
|
||||
return Ok(new { message = "you owned it." });
|
||||
}
|
||||
public class RoleInfo {
|
||||
public string Name { get; set; }
|
||||
public IEnumerable<string> Users { get; set; }
|
||||
}
|
||||
[Authorize(Roles=Constants.AdminGroupName)]
|
||||
|
||||
[Authorize(Roles = Constants.AdminGroupName)]
|
||||
[Produces("application/json")]
|
||||
public async Task<IActionResult> Index() {
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
var adminCount = await _userManager.GetUsersInRoleAsync(
|
||||
Constants.AdminGroupName);
|
||||
var youAreAdmin = await _userManager.IsInRoleAsync(
|
||||
await _userManager.FindByIdAsync(User.GetUserId()),
|
||||
Constants.AdminGroupName);
|
||||
var roles = _roleManager.Roles.Select(x=>
|
||||
new RoleInfo {
|
||||
Name = x.Name,
|
||||
Users = x.Users.Select( u=>u.UserId )
|
||||
} );
|
||||
return Ok (new { Roles = roles, AdminCount = adminCount.Count,
|
||||
YouAreAdmin = youAreAdmin
|
||||
var roles = _roleManager.Roles.Include(
|
||||
x => x.Users
|
||||
).Select(x => new RoleInfo {
|
||||
Id = x.Id,
|
||||
Name = x.Name,
|
||||
Users = x.Users.Select(u=>u.UserId).ToArray()
|
||||
});
|
||||
return View(new AdminViewModel
|
||||
{
|
||||
Roles = roles.ToArray(),
|
||||
AdminCount = adminCount.Count,
|
||||
YouAreAdmin = youAreAdmin
|
||||
});
|
||||
}
|
||||
|
||||
public IActionResult Role(string id)
|
||||
{
|
||||
IdentityRole role = _roleManager.Roles
|
||||
.Include(r=>r.Users).FirstOrDefault
|
||||
( r=> r.Id == id );
|
||||
var ri = GetRoleUserCollection(role);
|
||||
return View("Role",ri);
|
||||
}
|
||||
|
||||
public RoleUserCollection GetRoleUserCollection(IdentityRole role)
|
||||
{
|
||||
var result = new RoleUserCollection {
|
||||
Id = role.Id,
|
||||
Name = role.Name,
|
||||
Users = context.Users.Where(u=>role.Users.Any(ru => u.Id == ru.UserId))
|
||||
.Select( u => new UserInfo { UserName = u.UserName, Avatar = u.Avatar, UserId = u.Id } )
|
||||
.ToArray()
|
||||
};
|
||||
return result;
|
||||
}
|
||||
private void AddErrors(IdentityResult result)
|
||||
{
|
||||
foreach (var error in result.Errors)
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ using Microsoft.AspNet.Authorization;
|
|||
using Microsoft.Data.Entity;
|
||||
using Microsoft.Extensions.OptionsModel;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.ViewModels.Auth;
|
||||
|
||||
// For more information on enabling Web API for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860
|
||||
|
||||
|
|
@ -38,22 +39,27 @@ namespace Yavsc.Controllers
|
|||
|
||||
// GET: Blog
|
||||
[AllowAnonymous]
|
||||
public IActionResult Index(string id)
|
||||
public IActionResult Index(string id, int skip=0, int maxLen=25)
|
||||
{
|
||||
string uid = null;
|
||||
if (User.IsSignedIn())
|
||||
uid = User.GetUserId();
|
||||
if (!string.IsNullOrEmpty(id))
|
||||
return UserPosts(id);
|
||||
return View(_context.Blogspot.Include(
|
||||
b => b.Author
|
||||
).Where(p => p.Visible).Take(10));
|
||||
).Where(p => p.Visible || p.AuthorId == uid ).OrderByDescending(p => p.Posted)
|
||||
.Skip(skip).Take(maxLen));
|
||||
}
|
||||
|
||||
[Route("/Title/{id?}")]
|
||||
[AllowAnonymous]
|
||||
public IActionResult Title(string id)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
return View("Index", _context.Blogspot.Include(
|
||||
b => b.Author
|
||||
).Where(x => x.Title == id && x.Visible).ToList());
|
||||
).Where(x => x.Title == id && (x.Visible || x.AuthorId == uid )).ToList());
|
||||
}
|
||||
|
||||
[Route("/Blog/{id?}")]
|
||||
|
|
@ -88,7 +94,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
|
||||
return View(blog);
|
||||
}
|
||||
|
||||
|
|
@ -115,7 +121,7 @@ namespace Yavsc.Controllers
|
|||
_context.SaveChanges();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
_logger.LogWarning("Invalid Blog posted ...");
|
||||
ModelState.AddModelError("Unknown","Invalid Blog posted ...");
|
||||
return View(blog);
|
||||
}
|
||||
[Authorize()]
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ 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;
|
||||
|
||||
|
|
@ -42,6 +43,7 @@ namespace Yavsc.Controllers
|
|||
// GET: Client/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
SetAppTypesInputValues();
|
||||
return View();
|
||||
}
|
||||
|
||||
|
|
@ -62,8 +64,7 @@ namespace Yavsc.Controllers
|
|||
}
|
||||
private void SetAppTypesInputValues()
|
||||
{
|
||||
ViewData["Type"] =
|
||||
new SelectListItem[] {
|
||||
IEnumerable<SelectListItem> types = new SelectListItem[] {
|
||||
new SelectListItem {
|
||||
Text = ApplicationTypes.JavaScript.ToString(),
|
||||
Value = ((int) ApplicationTypes.JavaScript).ToString() },
|
||||
|
|
@ -72,6 +73,7 @@ namespace Yavsc.Controllers
|
|||
Value = ((int) ApplicationTypes.NativeConfidential).ToString()
|
||||
}
|
||||
};
|
||||
ViewData["Type"] = types;
|
||||
}
|
||||
// GET: Client/Edit/5
|
||||
public async Task<IActionResult> Edit(string id)
|
||||
|
|
|
|||
|
|
@ -161,7 +161,6 @@ namespace Yavsc.Controllers
|
|||
if (pro.Performer.Devices.Count > 0) {
|
||||
var regids = command.PerformerProfile.Performer
|
||||
.Devices.Select(d => d.GCMRegistrationId);
|
||||
var sregids = string.Join(",",regids);
|
||||
grep = await _GCMSender.NotifyBookQueryAsync(_googleSettings,regids,yaev);
|
||||
}
|
||||
// TODO setup a profile choice to allow notifications
|
||||
|
|
@ -175,7 +174,7 @@ namespace Yavsc.Controllers
|
|||
_siteSettings, _smtpSettings,
|
||||
command.PerformerProfile.Performer.Email,
|
||||
yaev.Topic+" "+yaev.Client.UserName,
|
||||
$"{yaev.Message}\r\n-- \r\n{yaev.Previsional}\r\n"
|
||||
$"{yaev.Message}\r\n-- \r\n{yaev.Previsional}\r\n{yaev.EventDate}\r\n"
|
||||
);
|
||||
}
|
||||
ViewBag.GoogleSettings = _googleSettings;
|
||||
|
|
|
|||
169
Yavsc/Controllers/DoController.cs
Normal file
169
Yavsc/Controllers/DoController.cs
Normal file
|
|
@ -0,0 +1,169 @@
|
|||
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 Models;
|
||||
using Models.Workflow;
|
||||
[Authorize]
|
||||
public class DoController : Controller
|
||||
{
|
||||
private ApplicationDbContext _context;
|
||||
|
||||
public DoController(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: /Do/Index
|
||||
[HttpGet]
|
||||
public IActionResult Index(string id)
|
||||
{
|
||||
if (id == null)
|
||||
id = User.GetUserId();
|
||||
|
||||
var userActivities = _context.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 IActionResult Details(string id, string activityCode)
|
||||
{
|
||||
if (id == null || activityCode == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
UserActivity userActivity = _context.UserActivities.Include(m=>m.Does)
|
||||
.Include(m=>m.User).Single(m => m.DoesCode == activityCode && m.UserId == id);
|
||||
if (userActivity == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
ViewBag.HasConfigurableSettings = (userActivity.Does.SettingsClassName != null);
|
||||
if (ViewBag.HasConfigurableSettings)
|
||||
ViewBag.SettingsClassControllerName = Startup.ProfileTypes[userActivity.Does.SettingsClassName].Name;
|
||||
|
||||
return View(userActivity);
|
||||
}
|
||||
|
||||
// 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(_context.Activities, "Code", "Name");
|
||||
//ViewData["UserId"] = userId;
|
||||
ViewBag.UserId = new SelectList(_context.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)
|
||||
{
|
||||
_context.UserActivities.Add(userActivity);
|
||||
_context.SaveChanges();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
ViewBag.DoesCode = new SelectList(_context.Activities, "Code", "Name", userActivity.DoesCode);
|
||||
ViewBag.UserId = new SelectList(_context.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 = _context.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(_context.Activities, "Code", "Does", userActivity.DoesCode);
|
||||
ViewData["UserId"] = new SelectList(_context.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)
|
||||
{
|
||||
_context.Update(userActivity);
|
||||
_context.SaveChanges();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
ViewData["DoesCode"] = new SelectList(_context.Activities, "Code", "Does", userActivity.DoesCode);
|
||||
ViewData["UserId"] = new SelectList(_context.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 = _context.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(string id, string activityCode)
|
||||
{
|
||||
UserActivity userActivity = _context.UserActivities.Single(m => m.UserId == id && m.DoesCode == activityCode);
|
||||
if (!User.IsInRole("Administrator"))
|
||||
if (User.GetUserId() != userActivity.UserId) {
|
||||
ModelState.AddModelError("User","You're not admin.");
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
_context.UserActivities.Remove(userActivity);
|
||||
_context.SaveChanges();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@ 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;
|
||||
|
|
@ -21,10 +22,13 @@ namespace Yavsc.Controllers
|
|||
private ApplicationDbContext _context;
|
||||
private SiteSettings _site;
|
||||
|
||||
public EstimateController(ApplicationDbContext context, IOptions<SiteSettings> siteSettings)
|
||||
IAuthorizationService authorizationService;
|
||||
|
||||
public EstimateController(ApplicationDbContext context, IAuthorizationService authorizationService, IOptions<SiteSettings> siteSettings)
|
||||
{
|
||||
_context = context;
|
||||
_site = siteSettings.Value;
|
||||
this.authorizationService = authorizationService;
|
||||
}
|
||||
|
||||
// GET: Estimate
|
||||
|
|
@ -41,7 +45,7 @@ namespace Yavsc.Controllers
|
|||
}
|
||||
|
||||
// GET: Estimate/Details/5
|
||||
public IActionResult Details(long? id)
|
||||
public async Task<IActionResult> Details(long? id)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
if (id == null)
|
||||
|
|
@ -62,6 +66,10 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
if (!await authorizationService.AuthorizeAsync(User, estimate, new ViewRequirement()))
|
||||
{
|
||||
return new ChallengeResult();
|
||||
}
|
||||
return View(estimate);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,11 +8,11 @@ using Microsoft.Extensions.Logging;
|
|||
using Yavsc.Models.Booking;
|
||||
using Yavsc.Helpers;
|
||||
using System;
|
||||
using Yavsc.ViewModels.FrontOffice;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
[ServiceFilter(typeof(LanguageActionFilter)),
|
||||
Route("do")]
|
||||
public class FrontOfficeController : Controller
|
||||
{
|
||||
ApplicationDbContext _context;
|
||||
|
|
@ -29,10 +29,20 @@ namespace Yavsc.Controllers
|
|||
}
|
||||
public ActionResult Index()
|
||||
{
|
||||
var latestPosts = _context.Blogspot.Where(
|
||||
x => x.Visible == true
|
||||
).OrderBy(x => x.Modified).Take(25).ToArray();
|
||||
return View(latestPosts);
|
||||
var uid = User.GetUserId();
|
||||
var now = DateTime.Now;
|
||||
|
||||
var model = new FrontOfficeIndexViewModel{
|
||||
EstimateToProduceCount = _context.Commands.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.Commands.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);
|
||||
}
|
||||
|
||||
[Route("Book/{id?}"), HttpGet]
|
||||
|
|
@ -42,17 +52,11 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
throw new NotImplementedException("No Activity code");
|
||||
}
|
||||
|
||||
ViewBag.Activities = _context.ActivityItems(id);
|
||||
ViewBag.Activity = _context.Activities.FirstOrDefault(
|
||||
a => a.Code == id);
|
||||
|
||||
return View(
|
||||
_context.Performers.Include(p => p.Performer).Where
|
||||
(p => p.ActivityCode == id && p.Active).OrderBy(
|
||||
x => x.MinDailyCost
|
||||
)
|
||||
);
|
||||
ViewBag.Activity = _context.Activities.FirstOrDefault(a=>a.Code == id);
|
||||
var result = _context.Performers
|
||||
.Include(p=>p.Performer).Where(p => p.Activity.Any(u=>u.DoesCode==id)).OrderBy( x => x.MinDailyCost );
|
||||
|
||||
return View(result);
|
||||
}
|
||||
|
||||
[Route("Book/{id}"), HttpPost]
|
||||
|
|
|
|||
153
Yavsc/Controllers/InstrumentationController.cs
Normal file
153
Yavsc/Controllers/InstrumentationController.cs
Normal file
|
|
@ -0,0 +1,153 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
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.Booking;
|
||||
using Yavsc.Models.Booking.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();
|
||||
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();
|
||||
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();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
119
Yavsc/Controllers/InstrumentsController.cs
Normal file
119
Yavsc/Controllers/InstrumentsController.cs
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
using System.Linq;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
using Models;
|
||||
using Models.Booking;
|
||||
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();
|
||||
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();
|
||||
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();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
119
Yavsc/Controllers/LocationTypesController.cs
Normal file
119
Yavsc/Controllers/LocationTypesController.cs
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
using System.Linq;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
using Models;
|
||||
using Models.Relationship;
|
||||
public class LocationTypesController : Controller
|
||||
{
|
||||
private ApplicationDbContext _context;
|
||||
|
||||
public LocationTypesController(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: LocationTypes
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View(_context.LocationType.ToList());
|
||||
}
|
||||
|
||||
// GET: LocationTypes/Details/5
|
||||
public IActionResult Details(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
LocationType locationType = _context.LocationType.Single(m => m.Id == id);
|
||||
if (locationType == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(locationType);
|
||||
}
|
||||
|
||||
// GET: LocationTypes/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: LocationTypes/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public IActionResult Create(LocationType locationType)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.LocationType.Add(locationType);
|
||||
_context.SaveChanges();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(locationType);
|
||||
}
|
||||
|
||||
// GET: LocationTypes/Edit/5
|
||||
public IActionResult Edit(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
LocationType locationType = _context.LocationType.Single(m => m.Id == id);
|
||||
if (locationType == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
return View(locationType);
|
||||
}
|
||||
|
||||
// POST: LocationTypes/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public IActionResult Edit(LocationType locationType)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Update(locationType);
|
||||
_context.SaveChanges();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(locationType);
|
||||
}
|
||||
|
||||
// GET: LocationTypes/Delete/5
|
||||
[ActionName("Delete")]
|
||||
public IActionResult Delete(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
LocationType locationType = _context.LocationType.Single(m => m.Id == id);
|
||||
if (locationType == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(locationType);
|
||||
}
|
||||
|
||||
// POST: LocationTypes/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public IActionResult DeleteConfirmed(long id)
|
||||
{
|
||||
LocationType locationType = _context.LocationType.Single(m => m.Id == id);
|
||||
_context.LocationType.Remove(locationType);
|
||||
_context.SaveChanges();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -110,11 +110,9 @@ namespace Yavsc.Controllers
|
|||
DiskUsage = user.DiskUsage,
|
||||
DiskQuota = user.DiskQuota
|
||||
};
|
||||
if (_dbContext.Performers.Any(x => x.PerformerId == user.Id))
|
||||
{
|
||||
var code = _dbContext.Performers.First(x => x.PerformerId == user.Id).ActivityCode;
|
||||
model.Activity = _dbContext.Activities.First(x => x.Code == code);
|
||||
}
|
||||
model.HaveProfessionalSettings = _dbContext.Performers.Any(x => x.PerformerId == user.Id);
|
||||
model.Activity = _dbContext.UserActivities.Include(a=>a.Does).Where(u=>u.UserId == user.Id)
|
||||
.ToList();
|
||||
return View(model);
|
||||
}
|
||||
|
||||
|
|
@ -491,16 +489,19 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
var user = GetCurrentUserAsync().Result;
|
||||
var uid = user.Id;
|
||||
bool existing = _dbContext.Performers.Any(x => x.PerformerId == uid);
|
||||
ViewBag.Activities = _dbContext.ActivityItems(null);
|
||||
var existing = _dbContext.Performers.Include(x => x.OrganizationAddress)
|
||||
.Include(p=>p.Activity).FirstOrDefault(x => x.PerformerId == uid);
|
||||
|
||||
ViewBag.GoogleSettings = _googleSettings;
|
||||
if (existing)
|
||||
if (existing!=null)
|
||||
{
|
||||
var currentProfile = _dbContext.Performers.Include(x => x.OrganizationAddress)
|
||||
.First(x => x.PerformerId == uid);
|
||||
string currentCode = currentProfile.ActivityCode;
|
||||
ViewBag.Activities = _dbContext.ActivityItems(existing.Activity);
|
||||
return View(currentProfile);
|
||||
}
|
||||
|
||||
ViewBag.Activities = _dbContext.ActivityItems(new List<UserActivity>());
|
||||
return View(new PerformerProfile
|
||||
{
|
||||
PerformerId = user.Id,
|
||||
|
|
@ -519,6 +520,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
|
||||
var exSiren = await _dbContext.ExceptionsSIREN.FirstOrDefaultAsync(
|
||||
ex => ex.SIREN == model.SIREN
|
||||
);
|
||||
|
|
@ -535,7 +537,7 @@ namespace Yavsc.Controllers
|
|||
"SIREN",
|
||||
_SR["Invalid company number"] + " (" + taskCheck.errorCode + ")"
|
||||
);
|
||||
_logger.LogInformation("Invalid company number, using key:" + _cinfoSettings.ApiKey);
|
||||
_logger.LogInformation($"Invalid company number: {model.SIREN}/{taskCheck.errorType}/{taskCheck.errorCode}/{taskCheck.errorMessage}" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -543,6 +545,7 @@ namespace Yavsc.Controllers
|
|||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex.Message);
|
||||
ModelState.AddModelError("SIREN", ex.Message);
|
||||
}
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
|
|
@ -553,14 +556,13 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
_dbContext.Map.Add(model.OrganizationAddress);
|
||||
}
|
||||
bool existing = _dbContext.Performers.Any(x => x.PerformerId == uid);
|
||||
if (existing)
|
||||
|
||||
if (_dbContext.Performers.Any(p=>p.PerformerId == uid))
|
||||
{
|
||||
_dbContext.Update(model);
|
||||
}
|
||||
else _dbContext.Performers.Add(model);
|
||||
_dbContext.SaveChanges();
|
||||
|
||||
// Give this user the Performer role
|
||||
if (!User.IsInRole("Performer"))
|
||||
await _userManager.AddToRoleAsync(user, "Performer");
|
||||
|
|
@ -571,8 +573,8 @@ namespace Yavsc.Controllers
|
|||
}
|
||||
else ModelState.AddModelError(string.Empty, $"Access denied ({uid} vs {model.PerformerId})");
|
||||
}
|
||||
|
||||
ViewBag.GoogleSettings = _googleSettings;
|
||||
ViewBag.Activities = _dbContext.ActivityItems(model.ActivityCode);
|
||||
return View(model);
|
||||
}
|
||||
|
||||
|
|
|
|||
119
Yavsc/Controllers/MusicalTendenciesController.cs
Normal file
119
Yavsc/Controllers/MusicalTendenciesController.cs
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
using System.Linq;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
using Models;
|
||||
using Models.Booking;
|
||||
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();
|
||||
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();
|
||||
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();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue