-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 85a8f69
Showing
78 changed files
with
4,886 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 14 | ||
VisualStudioVersion = 14.0.25420.1 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RifleRange", "RifleRange\RifleRange.csproj", "{0F3C5A9F-B8D9-4532-B35E-1EEBC601D4C0}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{0F3C5A9F-B8D9-4532-B35E-1EEBC601D4C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{0F3C5A9F-B8D9-4532-B35E-1EEBC601D4C0}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{0F3C5A9F-B8D9-4532-B35E-1EEBC601D4C0}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{0F3C5A9F-B8D9-4532-B35E-1EEBC601D4C0}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System; | ||
using RifleRange.Api; | ||
using System.Web.Http; | ||
|
||
namespace RifleRange.Controllers | ||
{ | ||
public class BaseController : ApiController | ||
{ | ||
protected ModelFactory TheFactory; | ||
|
||
public BaseController() | ||
{ | ||
TheFactory = new ModelFactory(); | ||
} | ||
[HttpGet] | ||
public IHttpActionResult CurrentTime() | ||
{ | ||
return Ok(DateTime.Now.ToString()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using RifleRange.DAL; | ||
using RifleRange.Api.Models; | ||
using System.Web.Http.Routing; | ||
using System.Net.Http; | ||
using System.Collections.Generic; | ||
|
||
namespace RifleRange.Api | ||
{ | ||
public class ModelFactory | ||
{ | ||
public ForumThread Create(rrForumThread Thread) | ||
{ | ||
ForumThread Model = new ForumThread(Thread); | ||
// Model.URL = UrlHelper.Link("Forum", new { id = Thread.ThreadId.ToString() }); | ||
|
||
return Model; | ||
} | ||
public ForumThread[] Create(LinkedList<rrForumThread> Threads) | ||
{ | ||
ForumThread[] Result = null; | ||
|
||
if (Threads != null) | ||
{ | ||
Result = new ForumThread[Threads.Count]; | ||
|
||
int i = 0; | ||
|
||
LinkedListNode<rrForumThread> Node = Threads.First; | ||
|
||
while (Node != null) | ||
{ | ||
Result[i] = Create(Node.Value); | ||
|
||
Node = Node.Next; | ||
i++; | ||
} | ||
|
||
} | ||
|
||
return Result; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Web; | ||
using System.Web.Http; | ||
using System.Web.Mvc; | ||
using System.Web.Routing; | ||
|
||
namespace RifleRange | ||
{ | ||
public class RouteConfig | ||
{ | ||
public static void RegisterRoutes(RouteCollection routes) | ||
{ | ||
routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); | ||
|
||
routes.MapRoute( | ||
name: "Default", | ||
url: "{controller}/{action}/{id}", | ||
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Web.Http; | ||
|
||
namespace RifleRange | ||
{ | ||
public static class WebApiConfig | ||
{ | ||
public static void Register(HttpConfiguration config) | ||
{ | ||
// TODO: Add any additional configuration code. | ||
|
||
// Web API routes | ||
config.MapHttpAttributeRoutes(); | ||
|
||
config.Routes.MapHttpRoute( | ||
name: "DefaultApi", | ||
routeTemplate: "api/{controller}/{id}", | ||
defaults: new { id = RouteParameter.Optional } | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
body { | ||
padding-top: 50px; | ||
padding-bottom: 20px; | ||
} | ||
|
||
/* Wrapping element */ | ||
/* Set some basic padding to keep content from hitting the edges */ | ||
.body-content { | ||
padding-left: 15px; | ||
padding-right: 15px; | ||
} | ||
|
||
/* Set widths on the form inputs since otherwise they're 100% wide */ | ||
input, | ||
select, | ||
textarea { | ||
max-width: 350px; | ||
} | ||
|
||
/* Carousel */ | ||
.carousel-caption p { | ||
font-size: 20px; | ||
line-height: 1.4; | ||
} | ||
|
||
/* Make .svg files in the carousel display properly in older browsers */ | ||
.carousel-inner .item img[src$=".svg"] | ||
{ | ||
width: 100%; | ||
} | ||
|
||
/* Hide/rearrange for smaller screens */ | ||
@media screen and (max-width: 767px) { | ||
/* Hide captions */ | ||
.carousel-caption { | ||
display: none | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
$.urlParam = function(name){ | ||
var results = new RegExp('[\?&]' + name + '=([^]*)').exec(window.location.href); | ||
if (results==null){ | ||
return null; | ||
} | ||
else{ | ||
return results[1] || 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Net; | ||
using System.Net.Http; | ||
using System.Web.Http; | ||
using System.Xml; | ||
using System.Text; | ||
using System.Runtime.Serialization.Json; | ||
using System.IO; | ||
using Newtonsoft.Json; | ||
using RifleRange.DAL; | ||
using RifleRange.Api.Models; | ||
|
||
|
||
namespace RifleRange.Controllers.API | ||
{ | ||
public class ForumController : BaseController | ||
{ | ||
const int ForumId = 2; | ||
|
||
[HttpGet] | ||
public HttpResponseMessage GetForumThread(int Id) | ||
{ | ||
HttpResponseMessage Response = null; | ||
|
||
try | ||
{ | ||
string JSON = "[\r\n " + GetThreadJSON(Id) + " \r\n]"; | ||
Response = new HttpResponseMessage() | ||
{ | ||
StatusCode = HttpStatusCode.OK, | ||
Content = new StringContent(content: JSON, encoding: UTF8Encoding.Default, mediaType: "application/json"), | ||
}; | ||
} | ||
catch (Exception ex) | ||
{ | ||
Response = Request.CreateErrorResponse(statusCode: HttpStatusCode.BadRequest, exception: ex); | ||
} | ||
return Response; | ||
} | ||
[Authorize] | ||
[HttpPost] | ||
[Route("api/Forum")] | ||
public IHttpActionResult Reply(ForumThreadReply Reply) | ||
{ | ||
IHttpActionResult Response = null; | ||
try | ||
{ | ||
if (!ModelState.IsValid) | ||
{ | ||
Response = BadRequest(ModelState); | ||
} | ||
else | ||
{ | ||
int ForumThreadId = rrForumThreadDB.InsertForumThreadReply( | ||
UserId: Reply.CreatedBy, | ||
ThreadParentId: Reply.ThreadParentId, | ||
Description: Uri.UnescapeDataString(Reply.Description)); | ||
|
||
string NewUrl = string.Format("api/Forum/{0}", ForumThreadId); | ||
Response = Created(NewUrl, string.Empty); | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
Response = BadRequest(ex.Message); | ||
} | ||
return Response; | ||
} | ||
[HttpPut] | ||
public IHttpActionResult Edit(int Id, [FromBody]string Description) | ||
{ | ||
IHttpActionResult Response = null; | ||
|
||
try | ||
{ | ||
LinkedList<rrForumThread> lstThread = rrForumThreadDB.GetForumThread(ForumId: ForumId, ThreadId: Id); | ||
if (lstThread.Count == 0) | ||
Response = NotFound(); | ||
else | ||
{ | ||
rrForumThread Thread = lstThread.First.Value; | ||
|
||
rrForumThreadDB.UpdateForumThread(ForumId: ForumId, ThreadId: Id, | ||
UserId: Thread.CreatedBy, Title: Thread.Title, | ||
Description: Uri.UnescapeDataString(Description), | ||
FileName: Thread.FileName); | ||
|
||
Response = Ok(); | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
Response = BadRequest(ex.Message); | ||
} | ||
return Response; | ||
} | ||
[HttpDelete] | ||
public IHttpActionResult Delete(int Id) | ||
{ | ||
IHttpActionResult Response = null; | ||
|
||
try | ||
{ | ||
LinkedList<rrForumThread> lstThread = rrForumThreadDB.GetForumThread(ForumId: ForumId, ThreadId: Id); | ||
if (lstThread.Count == 0) | ||
Response = NotFound(); | ||
else | ||
{ | ||
rrForumThread Thread = lstThread.First.Value; | ||
|
||
rrForumThreadDB.DeleteForumThread(ForumId: ForumId, ThreadId: Id); | ||
|
||
Response = Ok(); | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
Response = BadRequest(ex.Message); | ||
} | ||
return Response; | ||
} | ||
|
||
|
||
private string GetThreadJSON(int StartThreadId) | ||
{ | ||
LinkedList<rrForumThread> llThreads = rrForumThreadDB.GetForumThread(ForumId: ForumId, | ||
StartThreadId: StartThreadId, IncludeStartThread: true); | ||
|
||
|
||
return OutputThreadJSON(llThreads, StartThreadId); | ||
} | ||
|
||
private string OutputThreadJSON(LinkedList<rrForumThread> ThreadList, int ThreadId) | ||
{ | ||
LinkedListNode<rrForumThread> Node = ThreadList.First; | ||
|
||
while (Node != null) | ||
{ | ||
if (Node.Value.ThreadId == ThreadId) break; | ||
|
||
Node = Node.Next; | ||
} | ||
string JsonText = string.Empty; | ||
|
||
if (Node != null) | ||
{ | ||
ForumThread Thread = new ForumThread(ThreadList, Node); | ||
|
||
JsonText = JsonConvert.SerializeObject(Thread, Newtonsoft.Json.Formatting.Indented); | ||
} | ||
return JsonText; | ||
} | ||
private rrForumThread FindThreadById(LinkedList<rrForumThread> ThreadList, int ThreadId) | ||
{ | ||
rrForumThread Result = null; | ||
|
||
LinkedListNode<rrForumThread> Node = ThreadList.First; | ||
|
||
while (Node != null) | ||
{ | ||
rrForumThread Thread = Node.Value; | ||
if (Thread.ThreadId == ThreadId) | ||
{ | ||
Result = Thread; | ||
break; | ||
} | ||
|
||
Node = Node.Next; | ||
} | ||
|
||
return Result; | ||
} | ||
private LinkedList<rrForumThread> FindThreadByParentId(LinkedList<rrForumThread> ThreadList, | ||
int ThreadId) | ||
{ | ||
LinkedList<rrForumThread> Result = new LinkedList<rrForumThread>(); | ||
|
||
foreach (rrForumThread Thread in ThreadList) | ||
{ | ||
if (Thread.ThreadParentId == ThreadId) | ||
Result.AddLast(Thread); | ||
} | ||
|
||
return Result; | ||
} | ||
|
||
} | ||
} |
Oops, something went wrong.