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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 136 additions & 0 deletions CodeInspection/HomeControllerPartial.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using On_Call_Assistant.DAL;
using On_Call_Assistant.Models;


namespace On_Call_Assistant.Controllers
{
public partial class HomeController : Controller
{
private OnCallContext db = new OnCallContext();
public ActionResult RotationData(string start, string end, int ID = -1)
{
if (start == null || end == null)
{
start = end = DateTime.Today.ToString("u");
}
List<CalendarObject> rotationList = getRotations(start, end);
if (ID != -1)
{
rotationList = rotationList.Where(rot => rot.id == ID).ToList();
}
return Json(rotationList, JsonRequestBehavior.AllowGet);
}
public ActionResult RotationsWithoutURL(string start, string end, int ID = -1)
{
if (start == null || end == null)
{
start = end = DateTime.Today.ToString("u");
}
List<CalendarObject> rotationList = getRotations(start, end);
if (ID != -1)
{
rotationList = rotationList.Where(rot => rot.id == ID).ToList();
}
foreach (var rot in rotationList)
{
rot.url = null;
}
return Json(rotationList, JsonRequestBehavior.AllowGet);

}

public ActionResult AbsenceData(string start, string end)
{
if (start == null || end == null)
{
start = end = DateTime.Today.ToString("u");
}
DateTime beginDate = DateTime.Parse(start);
DateTime endDate = DateTime.Parse(end);
IList<CalendarObject> absenceList = new List<CalendarObject>();
var absences = db.outOfOffice.Include(o => o.employeeOut);
var filteredAbsences = filterAbsences(absences, beginDate, endDate);
foreach (var absence in filteredAbsences)
{
absenceList.Add(new CalendarObject
{
title = absence.employeeOut.firstName + " " + absence.employeeOut.lastName,
start = absence.startDate.ToString("u"),
end = absence.startDate.AddDays(absence.numHours / 8).ToString("u"),
color = "yellow",
url = String.Format("OutOfOffices/Details/{0}", absence.ID),
allDay = "false"
});
}
return Json(absenceList, JsonRequestBehavior.AllowGet);
}
private System.Collections.Hashtable getApplicationColors()
{
System.Collections.Hashtable colors = new System.Collections.Hashtable();
colors.Add(3, "MediumSeaGreen");
colors.Add(5, "Goldenrod");
colors.Add(8, "Cyan");
return colors;
}
private List<OutOfOffice> filterAbsences(IQueryable<OutOfOffice> absences, DateTime begin, DateTime end)
{
List<OutOfOffice> results = new List<OutOfOffice>();
foreach (var abs in absences)
{
if ((abs.startDate >= begin && abs.startDate <= end) || (abs.startDate.AddDays(abs.numHours / 8) >= begin && abs.startDate.AddDays(abs.numHours / 8) <= end))
{
results.Add(abs);
}
}
return results;
}

private List<CalendarObject> getRotations(string start, string end)
{
DateTime beginDate = DateTime.Parse(start);
DateTime endDate = DateTime.Parse(end);
List<CalendarObject> rotationList = new List<CalendarObject>();
var onCallRotations = db.onCallRotations.Include(o => o.employee);
onCallRotations = onCallRotations.Where(rot => (rot.startDate >= beginDate && rot.startDate <= endDate) || (rot.endDate >= beginDate && rot.endDate <= endDate));
System.Collections.Hashtable applicationColors = getApplicationColors();

foreach (var rotation in onCallRotations)
{
CalendarObject temp = new CalendarObject();
temp.id = rotation.employee.Application;
temp.title = rotation.employee.firstName + " " + rotation.employee.lastName;
if (!rotation.isPrimary)
temp.title = temp.title + " as Secondary";
temp.start = rotation.startDate.ToString("u");
temp.end = rotation.endDate.AddDays(1).ToString("u");
temp.color = applicationColors[rotation.employee.Application].ToString();
temp.url = String.Format("OnCallRotations/Details/{0}", rotation.rotationID);
temp.allDay = "true";
rotationList.Add(temp);
}

return rotationList;
}

}

public class CalendarObject
{
public int id { get; set; }
public string title { get; set; }
public string start { get; set; }
public string end { get; set; }
public string color { get; set; }
public string url { get; set; }
public string allDay { get; set; }

}

}
107 changes: 107 additions & 0 deletions CodeInspection/Index.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
@{
ViewBag.Title = "Home Page";
ViewBag.AppName = "On-Call Assistant";
}
@section styles {
<link href="~/Content/fullcalendar.css" rel="stylesheet" />
<link href="~/Content/fullcalendar.print.css" rel="stylesheet" media='print' />
}

@section scripts {
<script src="~/Scripts/lib/jquery.min.js"></script>
<script src="~/Scripts/lib/moment.min.js"></script>
<script src="~/Scripts/fullcalendar.js"></script>
<script src="~/Scripts/bootstrap.min.js"></script>
@*<script type="text/javascript" src="~/Scripts/lib/calendarEvents.js"></script>*@
<script type="text/javascript">
$(document).ready(function () {
$('#calendar').fullCalendar({
editable: false,
events: "/home/rotationdata/"@*for filtiring: /Home/RotationData?start=2015-03-01&end=2015-04-01&ID=5*@
});

$('#GenerateSchedule').click(function (event) {
event.preventDefault();
//probably could be refactored...
window.location.replace("/oncallrotations/generateSchedule");
});


@* Code for sorting rotations on the calendar by app starts here.
Grab each application and dynamically create a drop-down list item*@
@foreach(var app in ViewBag.applications)
{
@:$(".dropdown-menu").prepend('<li role="presentation"><a role="menuitem" tabindex="-1" href="#">' + '@app' + '</a></li>');
}
$(".dropdown-menu").prepend('<li role="presentation"><a role="menuitem" tabindex="-1" href="#">Remove Filters</a></li>');

@*Set the onclick event for the the dropdown list items*@
$('.dropdown').on('click', 'ul li a', function () {
var selectedAppName = $(this).text();
if (selectedAppName == 'Remove Filters') {
$('#calendar').fullCalendar('removeEvents');
$('#calendar').fullCalendar('addEventSource', "/Home/RotationData/" + selectedAppID);
$('#calendar').fullCalendar('rerenderEvents');
}
else {
var selectedAppID = selectedAppName.slice(selectedAppName.indexOf("-") + 1, selectedAppName.length);
console.log(selectedAppID);
$('#calendar').fullCalendar('removeEvents');
$('#calendar').fullCalendar('addEventSource', "/Home/RotationData?ID=" + selectedAppID);
$('#calendar').fullCalendar('rerenderEvents');
}
});
});



</script>





}
<div class="jumbotron">
<h1>@ViewBag.AppName</h1>

<p class="lead">Manage your on-call rotations, employees and summaries.</p>
<button id="GenerateSchedule" class="btn btn-primary btn-lg" type="button" onclick='this.disabled = "disabled";'>Generate Schedule</button>
<a href="../Home/Printable">print &raquo;</a>
</div>
@*Containers for the dropdown list of Application names (for sorting rotations on the calendar by app)*@
<div class="container">
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" id="menu1" data-toggle="dropdown">
Sort By App
<span class="caret"></span>
</button>
<ul id="dropDownList" class="dropdown-menu" role="menu" aria-labelledby="menu1"></ul>
</div>
</div>

<div class="row" style=" padding-top:20px">
<div class="col-md-9">
<div id="calendar"></div>
</div>


<div class="col-md-3">
<div class="row">
<h2>Employees</h2>
<p>Manage your employee data.</p>
<p><a class="btn btn-default" href="/employees">Go &raquo;</a></p>
<!-- <p><a href="/employees"><img src="~/Content/employeesButton.png"/></a></p>-->
</div>
<div class="row">
<h2>Manage On-Call Schedules</h2>
<p>View and edit the upcoming on-call rotations.</p>
<p><a class="btn btn-default" href="/oncallrotations">Go &raquo;</a></p>
</div>
<div class="row">
<h2>Manage Vacation</h2>
<p>Get a summary of upcoming vacation for employees and edit that time off as necessary.</p>
<p><a class="btn btn-default" href="/outofoffices">Go &raquo;</a></p>
</div>
</div>
</div>
2 changes: 1 addition & 1 deletion References.txt
Original file line number Diff line number Diff line change
Expand Up @@ -231,4 +231,4 @@ This reference details how to export data to an Excel spreadsheet using C#.
http://sourceforge.net/projects/itextsharp/

This is a .NET library for exporting data to a PDF file.
===================================================================
===================================================================
22 changes: 22 additions & 0 deletions Team 3 Presentation/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Auto detect text files and perform LF normalization
* text=auto

# Custom for Visual Studio
*.cs diff=csharp
*.sln merge=union
*.csproj merge=union
*.vbproj merge=union
*.fsproj merge=union
*.dbproj merge=union

# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
Loading