Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Binary file added Bug List.docx
Binary file not shown.
Binary file added Final_Project.zip
Binary file not shown.
Binary file modified Final_Project/.vs/Final_Project/DesignTimeBuild/.dtbcache.v2
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Final_Project/.vs/Final_Project/v17/.futdcache.v2
Binary file not shown.
Binary file modified Final_Project/.vs/Final_Project/v17/.suo
Binary file not shown.
Binary file not shown.
Binary file modified Final_Project/.vs/ProjectEvaluation/final_project.metadata.v5.2
Binary file not shown.
Binary file modified Final_Project/.vs/ProjectEvaluation/final_project.projects.v5.2
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,26 @@
*@
@{
}
<h1>Your Account</h1>

@if(User.IsInRole("Admin"))
{
<h1>Welcome @User.Identity?.Name</h1>
<P>You are a site administrator</P>
}
else if(User.IsInRole("Student"))
{
<h1>Welcome @User.Identity?.Name</h1>
<p>You are a registered Student</p>
}
else
{
<h1>Congratulations, @User.Identity?.Name on joining Team 6419 ICE!</h1>
<p>Your account is not yet confirmed by a Mentor</p>
}
<div>

</div>
<h1>Your Account</h1>
<a method="get" asp-action="ChangePassword" asp-controller="Account" asp-area="">
<input type="submit" value="Change Password"
class="btn btn-outline-dark" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
using Final_Project.Areas.MemberLinks.Models.ViewModels;
using Final_Project.Areas.MemberLinks.Models;
using Final_Project.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using System.Data;

namespace Final_Project.Areas.MemberLinks.Controllers
{
[Authorize(Roles = "Student, Admin")]
[Area("MemberLinks")]
public class LinkController : Controller
{
private SiteContext _siteContext;
private List<Models.DomainModels.Link> links = new List<Models.DomainModels.Link>();

public LinkController(SiteContext ctx)
{
_siteContext = ctx;
links = _siteContext.Links
.OrderBy(c => c.id)
.ToList();
}

[HttpGet]
public IActionResult Links(string teamType)
{
List<Models.DomainModels.Link> links = new List<Models.DomainModels.Link>() ;
// links = _siteContext.Links
//.OrderBy(p => p.id).ToList();
LinksModel viewModel = new LinksModel();
foreach (Final_Project.Areas.MemberLinks.Models.DomainModels.Link link in _siteContext.Links)
{
if(link.teamtype==teamType)
{
links.Add(link);
viewModel.type = teamType;
}
}
if(links.Count==0)
{
foreach(Final_Project.Areas.MemberLinks.Models.DomainModels.Link link in _siteContext.Links)
{
links.Add(link);
}
viewModel.type = "All";
}

viewModel.links = links;
return View(viewModel);
//return View(model);
}
[HttpPost]
public RedirectToActionResult Delete(int id)
{
foreach (Models.DomainModels.Link link in _siteContext.Links)
{
if (link.id == id)
{
_siteContext.Links.Remove(link);
}
}


//_siteContext.Messages.Remove(message);

_siteContext.SaveChanges();

return RedirectToAction("Links");
}
[HttpGet]
public IActionResult AddLink()
{
AddLinkModel model = new AddLinkModel();
return View(model);
}
[HttpPost]
public IActionResult AddLink(AddLinkModel model)
{


if (ModelState.IsValid)
{
Models.DomainModels.Link link = new Models.DomainModels.Link();
link.name = model.name;
link.LinkData = model.LinkData;
link.teamtype = model.teamtype;

_siteContext.Links.Add(link);
_siteContext.SaveChanges();
return View("redirect");
}
else
{
return View(model);
}


}
public IActionResult Link(int id)
{
foreach (Final_Project.Areas.MemberLinks.Models.DomainModels.Link link in _siteContext.Links)
{

if (link.id == id)
{
return View(link);
}
}
return View();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Final_Project.Areas.Team.Models.ViewModels;
using System.ComponentModel.DataAnnotations;

namespace Final_Project.Areas.MemberLinks.Models.DomainModels
{
public class Link
{
[Required(ErrorMessage = "Please enter a resource name")]
[StringLength(100)]
public string name { get; set; } = string.Empty;

[Required(ErrorMessage = "Please enter the link to the resource")]
[StringLength(3000)]
public string LinkData { get; set; } = string.Empty;
public string teamtype { get; set; }=string.Empty;

[Key]
public int id { get; set; }

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//using Microsoft.Build.Framework;
using Final_Project.Areas.MemberLinks.Models.DomainModels;
using Final_Project.Areas.MemberLinks.Models.ViewModels;
using System.ComponentModel.DataAnnotations;
namespace Final_Project.Areas.MemberLinks.Models
{
public class LinkViewModel
{
[Required(ErrorMessage = "Please enter a resource name")]
[StringLength(100)]
public string name { get; set; } = string.Empty;

[Required(ErrorMessage = "Please enter the link to the resource")]
[StringLength(3000)]
public string LinkData { get; set; } = string.Empty;

[Key]
public int id { get; set; }
}
}
10 changes: 10 additions & 0 deletions Final_Project/Final_Project/Areas/MemberLinks/Models/LinksModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

namespace Final_Project.Areas.MemberLinks.Models

{
public class LinksModel
{
public List<Final_Project.Areas.MemberLinks.Models.DomainModels.Link> links { get; set; } = null!;
public string type { get; set; }=string.Empty;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Final_Project.Areas.MemberLinks.Models.DomainModels;
using System.ComponentModel.DataAnnotations;

namespace Final_Project.Areas.MemberLinks.Models.ViewModels
{
public class AddLinkModel
{


[Required(ErrorMessage = "Please enter a resource name")]
[StringLength(100)]
public string name { get; set; } = string.Empty;

[Required(ErrorMessage = "Please enter the link to the resource")]
[StringLength(3000)]
public string LinkData { get; set; } = string.Empty;

[Key]
public int id { get; set; }
[Required(ErrorMessage = "Please enter a team type")]
[StringLength(3,ErrorMessage ="Select a team type")]
public string teamtype { get; set; }= string.Empty;

}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
@using Final_Project.Areas.MemberLinks.Models.ViewModels;
@model Final_Project.Areas.MemberLinks.Models.ViewModels.AddLinkModel
@{
ViewBag.Title = "Add Resource";
}

<h2>Add Team</h2>

<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<form method="post" asp-action="AddLink">
<div class="row mb-2">
<label class="col-form-label col-md-2">Name of Resource:</label>
<div class="col-md-4">
<input asp-for="name" class="form-control" />
</div>
<div class="col">
<span asp-validation-for="name" class="text-danger"></span>
</div>
</div>
<div class="row mb-2">
<label class="col-form-label col-md-2">Link:</label>
<div class="col-md-4">
<input asp-for="LinkData" class="form-control" />
</div>
<div class="col">
<span asp-validation-for="LinkData" class="text-danger"></span>
</div>
</div>
<div class="row mb-2">
<label class="col-form-label col-md-2">Program:</label>
<div class="col-md-4 dropdown">

<div class="dropdown">
<select asp-for="teamtype" class="dropdown">
<option>Select Team Type</option>
<option>FRC</option>
<option>FTC</option>
<option>FLL</option>
</select>
</div>
<div class="col">
<span asp-validation-for="teamtype" class="text-danger"></span>
</div>
</div>

<div class="row">
<div class="col offset-md-2">
<button type="submit" class="btn btn-primary">Add</button>
<a asp-action="Links" asp-controller="Link" class="btn btn-primary">Cancel</a>
</div>
</div>
</form>
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
@using Final_Project.Models.DomainModels;
@using Final_Project.Areas.MemberLinks.Models.DomainModels
@model Final_Project.Areas.MemberLinks.Models.LinksModel
@using Final_Project.Areas.Mentor.Controllers;
@{
ViewData["Title"] = " | Teams";
}
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
@if (!(Model.type == "All"))
{
<h1 class="mb-2">@Model.type Resources</h1>
}
else
{
<h1 class="mb-2">Showing all Resources</h1>
}

@if (User.IsInRole("Admin"))
{
<h5 class="mt-2"><a asp-action="AddLink">Add a link</a></h5>
}

<table class="table table-bordered table-striped table-sm">
<thead>
<tr><th> Resource Name</th><th>Link</th><th></th><th></th><th></th></tr>
</thead>
<tbody>

@if (Model.links.Count() == 0)
{
<tr><td colspan="5">There are no links</td></tr>
}
else
{

@foreach (Link link in Model.links)
{
<tr>
<td>@link.name</td>

@if (link.LinkData.ToLower().Contains("https://"))
{
<td><a href=@link.LinkData target="_blank">View this Resource</a></td>
}
else
{


<td><a href =https://@link.LinkData target="_blank">View this Resource</a></td>
}



@if (User.IsInRole("Admin"))
{
<td>
<form method="post" asp-action="Delete"
asp-route-id="@link.id">
<button type="submit" class="btn btn-primary">
Delete link
</button>
</form>
</td>
}



</tr>
}

}

</tbody>
</table>


Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

<h1>Link added successfully</h1>
<a asp-action="Index" asp-controller="Home" asp-area="" class="btn btn-primary">Home</a>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@using Final_Project
@using Final_Project.Models
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@{
Layout = "_Layout";
}
Loading