diff --git a/Browar/Browar.sln b/Browar/Browar.sln index f00a607..78f7334 100644 --- a/Browar/Browar.sln +++ b/Browar/Browar.sln @@ -4,6 +4,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00 VisualStudioVersion = 12.0.30501.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Browar", "Browar\Browar.csproj", "{6E3DB236-3256-491D-B7C5-65B3573D34BB}" + ProjectSection(ProjectDependencies) = postProject + {BDE37148-3388-432D-9BA7-595915F45AAD} = {BDE37148-3388-432D-9BA7-595915F45AAD} + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serwer", "Serwer\Serwer.csproj", "{BDE37148-3388-432D-9BA7-595915F45AAD}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -15,6 +20,10 @@ Global {6E3DB236-3256-491D-B7C5-65B3573D34BB}.Debug|Any CPU.Build.0 = Debug|Any CPU {6E3DB236-3256-491D-B7C5-65B3573D34BB}.Release|Any CPU.ActiveCfg = Release|Any CPU {6E3DB236-3256-491D-B7C5-65B3573D34BB}.Release|Any CPU.Build.0 = Release|Any CPU + {BDE37148-3388-432D-9BA7-595915F45AAD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BDE37148-3388-432D-9BA7-595915F45AAD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BDE37148-3388-432D-9BA7-595915F45AAD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BDE37148-3388-432D-9BA7-595915F45AAD}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Browar/Browar.v12.suo b/Browar/Browar.v12.suo index 10eef38..16cb5b1 100644 Binary files a/Browar/Browar.v12.suo and b/Browar/Browar.v12.suo differ diff --git a/Browar/Browar/App_Data/BrowarContext-20141015185410.mdf b/Browar/Browar/App_Data/BrowarContext-20141015185410.mdf index 2ce91ef..4253d0c 100644 Binary files a/Browar/Browar/App_Data/BrowarContext-20141015185410.mdf and b/Browar/Browar/App_Data/BrowarContext-20141015185410.mdf differ diff --git a/Browar/Browar/App_Data/BrowarContext-20141015185410_log.ldf b/Browar/Browar/App_Data/BrowarContext-20141015185410_log.ldf index b189376..bb83ece 100644 Binary files a/Browar/Browar/App_Data/BrowarContext-20141015185410_log.ldf and b/Browar/Browar/App_Data/BrowarContext-20141015185410_log.ldf differ diff --git a/Browar/Browar/Areas/HelpPage/ApiDescriptionExtensions.cs b/Browar/Browar/Areas/HelpPage/ApiDescriptionExtensions.cs deleted file mode 100644 index 4ab963d..0000000 --- a/Browar/Browar/Areas/HelpPage/ApiDescriptionExtensions.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System; -using System.Text; -using System.Web; -using System.Web.Http.Description; - -namespace Browar.Areas.HelpPage -{ - public static class ApiDescriptionExtensions - { - /// - /// Generates an URI-friendly ID for the . E.g. "Get-Values-id_name" instead of "GetValues/{id}?name={name}" - /// - /// The . - /// The ID as a string. - public static string GetFriendlyId(this ApiDescription description) - { - string path = description.RelativePath; - string[] urlParts = path.Split('?'); - string localPath = urlParts[0]; - string queryKeyString = null; - if (urlParts.Length > 1) - { - string query = urlParts[1]; - string[] queryKeys = HttpUtility.ParseQueryString(query).AllKeys; - queryKeyString = String.Join("_", queryKeys); - } - - StringBuilder friendlyPath = new StringBuilder(); - friendlyPath.AppendFormat("{0}-{1}", - description.HttpMethod.Method, - localPath.Replace("/", "-").Replace("{", String.Empty).Replace("}", String.Empty)); - if (queryKeyString != null) - { - friendlyPath.AppendFormat("_{0}", queryKeyString); - } - return friendlyPath.ToString(); - } - } -} \ No newline at end of file diff --git a/Browar/Browar/Areas/HelpPage/App_Start/HelpPageConfig.cs b/Browar/Browar/Areas/HelpPage/App_Start/HelpPageConfig.cs deleted file mode 100644 index c673e5a..0000000 --- a/Browar/Browar/Areas/HelpPage/App_Start/HelpPageConfig.cs +++ /dev/null @@ -1,113 +0,0 @@ -// Uncomment the following to provide samples for PageResult. Must also add the Microsoft.AspNet.WebApi.OData -// package to your project. -////#define Handle_PageResultOfT - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -using System.Linq; -using System.Net.Http.Headers; -using System.Reflection; -using System.Web; -using System.Web.Http; -#if Handle_PageResultOfT -using System.Web.Http.OData; -#endif - -namespace Browar.Areas.HelpPage -{ - /// - /// Use this class to customize the Help Page. - /// For example you can set a custom to supply the documentation - /// or you can provide the samples for the requests/responses. - /// - public static class HelpPageConfig - { - [SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", - MessageId = "Browar.Areas.HelpPage.TextSample.#ctor(System.String)", - Justification = "End users may choose to merge this string with existing localized resources.")] - [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", - MessageId = "bsonspec", - Justification = "Part of a URI.")] - public static void Register(HttpConfiguration config) - { - //// Uncomment the following to use the documentation from XML documentation file. - //config.SetDocumentationProvider(new XmlDocumentationProvider(HttpContext.Current.Server.MapPath("~/App_Data/XmlDocument.xml"))); - - //// Uncomment the following to use "sample string" as the sample for all actions that have string as the body parameter or return type. - //// Also, the string arrays will be used for IEnumerable. The sample objects will be serialized into different media type - //// formats by the available formatters. - //config.SetSampleObjects(new Dictionary - //{ - // {typeof(string), "sample string"}, - // {typeof(IEnumerable), new string[]{"sample 1", "sample 2"}} - //}); - - // Extend the following to provide factories for types not handled automatically (those lacking parameterless - // constructors) or for which you prefer to use non-default property values. Line below provides a fallback - // since automatic handling will fail and GeneratePageResult handles only a single type. -#if Handle_PageResultOfT - config.GetHelpPageSampleGenerator().SampleObjectFactories.Add(GeneratePageResult); -#endif - - // Extend the following to use a preset object directly as the sample for all actions that support a media - // type, regardless of the body parameter or return type. The lines below avoid display of binary content. - // The BsonMediaTypeFormatter (if available) is not used to serialize the TextSample object. - config.SetSampleForMediaType( - new TextSample("Binary JSON content. See http://bsonspec.org for details."), - new MediaTypeHeaderValue("application/bson")); - - //// Uncomment the following to use "[0]=foo&[1]=bar" directly as the sample for all actions that support form URL encoded format - //// and have IEnumerable as the body parameter or return type. - //config.SetSampleForType("[0]=foo&[1]=bar", new MediaTypeHeaderValue("application/x-www-form-urlencoded"), typeof(IEnumerable)); - - //// Uncomment the following to use "1234" directly as the request sample for media type "text/plain" on the controller named "Values" - //// and action named "Put". - //config.SetSampleRequest("1234", new MediaTypeHeaderValue("text/plain"), "Values", "Put"); - - //// Uncomment the following to use the image on "../images/aspNetHome.png" directly as the response sample for media type "image/png" - //// on the controller named "Values" and action named "Get" with parameter "id". - //config.SetSampleResponse(new ImageSample("../images/aspNetHome.png"), new MediaTypeHeaderValue("image/png"), "Values", "Get", "id"); - - //// Uncomment the following to correct the sample request when the action expects an HttpRequestMessage with ObjectContent. - //// The sample will be generated as if the controller named "Values" and action named "Get" were having string as the body parameter. - //config.SetActualRequestType(typeof(string), "Values", "Get"); - - //// Uncomment the following to correct the sample response when the action returns an HttpResponseMessage with ObjectContent. - //// The sample will be generated as if the controller named "Values" and action named "Post" were returning a string. - //config.SetActualResponseType(typeof(string), "Values", "Post"); - } - -#if Handle_PageResultOfT - private static object GeneratePageResult(HelpPageSampleGenerator sampleGenerator, Type type) - { - if (type.IsGenericType) - { - Type openGenericType = type.GetGenericTypeDefinition(); - if (openGenericType == typeof(PageResult<>)) - { - // Get the T in PageResult - Type[] typeParameters = type.GetGenericArguments(); - Debug.Assert(typeParameters.Length == 1); - - // Create an enumeration to pass as the first parameter to the PageResult constuctor - Type itemsType = typeof(List<>).MakeGenericType(typeParameters); - object items = sampleGenerator.GetSampleObject(itemsType); - - // Fill in the other information needed to invoke the PageResult constuctor - Type[] parameterTypes = new Type[] { itemsType, typeof(Uri), typeof(long?), }; - object[] parameters = new object[] { items, null, (long)ObjectGenerator.DefaultCollectionSize, }; - - // Call PageResult(IEnumerable items, Uri nextPageLink, long? count) constructor - ConstructorInfo constructor = type.GetConstructor(parameterTypes); - return constructor.Invoke(parameters); - } - } - - return null; - } -#endif - } -} \ No newline at end of file diff --git a/Browar/Browar/Areas/HelpPage/Controllers/HelpController.cs b/Browar/Browar/Areas/HelpPage/Controllers/HelpController.cs deleted file mode 100644 index d47d9b9..0000000 --- a/Browar/Browar/Areas/HelpPage/Controllers/HelpController.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; -using System.Web.Http; -using System.Web.Mvc; -using Browar.Areas.HelpPage.ModelDescriptions; -using Browar.Areas.HelpPage.Models; - -namespace Browar.Areas.HelpPage.Controllers -{ - /// - /// The controller that will handle requests for the help page. - /// - public class HelpController : Controller - { - private const string ErrorViewName = "Error"; - - public HelpController() - : this(GlobalConfiguration.Configuration) - { - } - - public HelpController(HttpConfiguration config) - { - Configuration = config; - } - - public HttpConfiguration Configuration { get; private set; } - - public ActionResult Index() - { - ViewBag.DocumentationProvider = Configuration.Services.GetDocumentationProvider(); - return View(Configuration.Services.GetApiExplorer().ApiDescriptions); - } - - public ActionResult Api(string apiId) - { - if (!String.IsNullOrEmpty(apiId)) - { - HelpPageApiModel apiModel = Configuration.GetHelpPageApiModel(apiId); - if (apiModel != null) - { - return View(apiModel); - } - } - - return View(ErrorViewName); - } - - public ActionResult ResourceModel(string modelName) - { - if (!String.IsNullOrEmpty(modelName)) - { - ModelDescriptionGenerator modelDescriptionGenerator = Configuration.GetModelDescriptionGenerator(); - ModelDescription modelDescription; - if (modelDescriptionGenerator.GeneratedModels.TryGetValue(modelName, out modelDescription)) - { - return View(modelDescription); - } - } - - return View(ErrorViewName); - } - } -} \ No newline at end of file diff --git a/Browar/Browar/Areas/HelpPage/HelpPage.css b/Browar/Browar/Areas/HelpPage/HelpPage.css deleted file mode 100644 index 0bba6d2..0000000 --- a/Browar/Browar/Areas/HelpPage/HelpPage.css +++ /dev/null @@ -1,133 +0,0 @@ -.help-page h1, -.help-page .h1, -.help-page h2, -.help-page .h2, -.help-page h3, -.help-page .h3, -#body.help-page, -.help-page-table th, -.help-page-table pre, -.help-page-table p { - font-family: "Segoe UI Light", Frutiger, "Frutiger Linotype", "Dejavu Sans", "Helvetica Neue", Arial, sans-serif; -} - -.help-page pre.wrapped { - white-space: -moz-pre-wrap; - white-space: -pre-wrap; - white-space: -o-pre-wrap; - white-space: pre-wrap; -} - -.help-page .warning-message-container { - margin-top: 20px; - padding: 0 10px; - color: #525252; - background: #EFDCA9; - border: 1px solid #CCCCCC; -} - -.help-page-table { - width: 100%; - border-collapse: collapse; - text-align: left; - margin: 0px 0px 20px 0px; - border-top: 1px solid #D4D4D4; -} - -.help-page-table th { - text-align: left; - font-weight: bold; - border-bottom: 1px solid #D4D4D4; - padding: 5px 6px 5px 6px; -} - -.help-page-table td { - border-bottom: 1px solid #D4D4D4; - padding: 10px 8px 10px 8px; - vertical-align: top; -} - -.help-page-table pre, -.help-page-table p { - margin: 0px; - padding: 0px; - font-family: inherit; - font-size: 100%; -} - -.help-page-table tbody tr:hover td { - background-color: #F3F3F3; -} - -.help-page a:hover { - background-color: transparent; -} - -.help-page .sample-header { - border: 2px solid #D4D4D4; - background: #76B8DB; - color: #FFFFFF; - padding: 8px 15px; - border-bottom: none; - display: inline-block; - margin: 10px 0px 0px 0px; -} - -.help-page .sample-content { - display: block; - border-width: 0; - padding: 15px 20px; - background: #FFFFFF; - border: 2px solid #D4D4D4; - margin: 0px 0px 10px 0px; -} - -.help-page .api-name { - width: 40%; -} - -.help-page .api-documentation { - width: 60%; -} - -.help-page .parameter-name { - width: 20%; -} - -.help-page .parameter-documentation { - width: 40%; -} - -.help-page .parameter-type { - width: 20%; -} - -.help-page .parameter-annotations { - width: 20%; -} - -.help-page h1, -.help-page .h1 { - font-size: 36px; -} - -.help-page h2, -.help-page .h2 { - font-size: 24px; -} - -.help-page h3, -.help-page .h3 { - font-size: 20px; -} - -#body.help-page { - font-size: 14px; - line-height: 143%; - color: #333; -} - -.help-page a { - color: #00abec; - text-decoration: none; -} diff --git a/Browar/Browar/Areas/HelpPage/HelpPageAreaRegistration.cs b/Browar/Browar/Areas/HelpPage/HelpPageAreaRegistration.cs deleted file mode 100644 index 82d0fdf..0000000 --- a/Browar/Browar/Areas/HelpPage/HelpPageAreaRegistration.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Web.Http; -using System.Web.Mvc; - -namespace Browar.Areas.HelpPage -{ - public class HelpPageAreaRegistration : AreaRegistration - { - public override string AreaName - { - get - { - return "HelpPage"; - } - } - - public override void RegisterArea(AreaRegistrationContext context) - { - context.MapRoute( - "HelpPage_Default", - "Help/{action}/{apiId}", - new { controller = "Help", action = "Index", apiId = UrlParameter.Optional }); - - HelpPageConfig.Register(GlobalConfiguration.Configuration); - } - } -} \ No newline at end of file diff --git a/Browar/Browar/Areas/HelpPage/HelpPageConfigurationExtensions.cs b/Browar/Browar/Areas/HelpPage/HelpPageConfigurationExtensions.cs deleted file mode 100644 index f01d4c1..0000000 --- a/Browar/Browar/Areas/HelpPage/HelpPageConfigurationExtensions.cs +++ /dev/null @@ -1,435 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -using System.Globalization; -using System.Linq; -using System.Net.Http; -using System.Net.Http.Headers; -using System.Web.Http; -using System.Web.Http.Controllers; -using System.Web.Http.Description; -using Browar.Areas.HelpPage.ModelDescriptions; -using Browar.Areas.HelpPage.Models; - -namespace Browar.Areas.HelpPage -{ - public static class HelpPageConfigurationExtensions - { - private const string ApiModelPrefix = "MS_HelpPageApiModel_"; - - /// - /// Sets the documentation provider for help page. - /// - /// The . - /// The documentation provider. - public static void SetDocumentationProvider(this HttpConfiguration config, IDocumentationProvider documentationProvider) - { - config.Services.Replace(typeof(IDocumentationProvider), documentationProvider); - } - - /// - /// Sets the objects that will be used by the formatters to produce sample requests/responses. - /// - /// The . - /// The sample objects. - public static void SetSampleObjects(this HttpConfiguration config, IDictionary sampleObjects) - { - config.GetHelpPageSampleGenerator().SampleObjects = sampleObjects; - } - - /// - /// Sets the sample request directly for the specified media type and action. - /// - /// The . - /// The sample request. - /// The media type. - /// Name of the controller. - /// Name of the action. - public static void SetSampleRequest(this HttpConfiguration config, object sample, MediaTypeHeaderValue mediaType, string controllerName, string actionName) - { - config.GetHelpPageSampleGenerator().ActionSamples.Add(new HelpPageSampleKey(mediaType, SampleDirection.Request, controllerName, actionName, new[] { "*" }), sample); - } - - /// - /// Sets the sample request directly for the specified media type and action with parameters. - /// - /// The . - /// The sample request. - /// The media type. - /// Name of the controller. - /// Name of the action. - /// The parameter names. - public static void SetSampleRequest(this HttpConfiguration config, object sample, MediaTypeHeaderValue mediaType, string controllerName, string actionName, params string[] parameterNames) - { - config.GetHelpPageSampleGenerator().ActionSamples.Add(new HelpPageSampleKey(mediaType, SampleDirection.Request, controllerName, actionName, parameterNames), sample); - } - - /// - /// Sets the sample request directly for the specified media type of the action. - /// - /// The . - /// The sample response. - /// The media type. - /// Name of the controller. - /// Name of the action. - public static void SetSampleResponse(this HttpConfiguration config, object sample, MediaTypeHeaderValue mediaType, string controllerName, string actionName) - { - config.GetHelpPageSampleGenerator().ActionSamples.Add(new HelpPageSampleKey(mediaType, SampleDirection.Response, controllerName, actionName, new[] { "*" }), sample); - } - - /// - /// Sets the sample response directly for the specified media type of the action with specific parameters. - /// - /// The . - /// The sample response. - /// The media type. - /// Name of the controller. - /// Name of the action. - /// The parameter names. - public static void SetSampleResponse(this HttpConfiguration config, object sample, MediaTypeHeaderValue mediaType, string controllerName, string actionName, params string[] parameterNames) - { - config.GetHelpPageSampleGenerator().ActionSamples.Add(new HelpPageSampleKey(mediaType, SampleDirection.Response, controllerName, actionName, parameterNames), sample); - } - - /// - /// Sets the sample directly for all actions with the specified media type. - /// - /// The . - /// The sample. - /// The media type. - public static void SetSampleForMediaType(this HttpConfiguration config, object sample, MediaTypeHeaderValue mediaType) - { - config.GetHelpPageSampleGenerator().ActionSamples.Add(new HelpPageSampleKey(mediaType), sample); - } - - /// - /// Sets the sample directly for all actions with the specified type and media type. - /// - /// The . - /// The sample. - /// The media type. - /// The parameter type or return type of an action. - public static void SetSampleForType(this HttpConfiguration config, object sample, MediaTypeHeaderValue mediaType, Type type) - { - config.GetHelpPageSampleGenerator().ActionSamples.Add(new HelpPageSampleKey(mediaType, type), sample); - } - - /// - /// Specifies the actual type of passed to the in an action. - /// The help page will use this information to produce more accurate request samples. - /// - /// The . - /// The type. - /// Name of the controller. - /// Name of the action. - public static void SetActualRequestType(this HttpConfiguration config, Type type, string controllerName, string actionName) - { - config.GetHelpPageSampleGenerator().ActualHttpMessageTypes.Add(new HelpPageSampleKey(SampleDirection.Request, controllerName, actionName, new[] { "*" }), type); - } - - /// - /// Specifies the actual type of passed to the in an action. - /// The help page will use this information to produce more accurate request samples. - /// - /// The . - /// The type. - /// Name of the controller. - /// Name of the action. - /// The parameter names. - public static void SetActualRequestType(this HttpConfiguration config, Type type, string controllerName, string actionName, params string[] parameterNames) - { - config.GetHelpPageSampleGenerator().ActualHttpMessageTypes.Add(new HelpPageSampleKey(SampleDirection.Request, controllerName, actionName, parameterNames), type); - } - - /// - /// Specifies the actual type of returned as part of the in an action. - /// The help page will use this information to produce more accurate response samples. - /// - /// The . - /// The type. - /// Name of the controller. - /// Name of the action. - public static void SetActualResponseType(this HttpConfiguration config, Type type, string controllerName, string actionName) - { - config.GetHelpPageSampleGenerator().ActualHttpMessageTypes.Add(new HelpPageSampleKey(SampleDirection.Response, controllerName, actionName, new[] { "*" }), type); - } - - /// - /// Specifies the actual type of returned as part of the in an action. - /// The help page will use this information to produce more accurate response samples. - /// - /// The . - /// The type. - /// Name of the controller. - /// Name of the action. - /// The parameter names. - public static void SetActualResponseType(this HttpConfiguration config, Type type, string controllerName, string actionName, params string[] parameterNames) - { - config.GetHelpPageSampleGenerator().ActualHttpMessageTypes.Add(new HelpPageSampleKey(SampleDirection.Response, controllerName, actionName, parameterNames), type); - } - - /// - /// Gets the help page sample generator. - /// - /// The . - /// The help page sample generator. - public static HelpPageSampleGenerator GetHelpPageSampleGenerator(this HttpConfiguration config) - { - return (HelpPageSampleGenerator)config.Properties.GetOrAdd( - typeof(HelpPageSampleGenerator), - k => new HelpPageSampleGenerator()); - } - - /// - /// Sets the help page sample generator. - /// - /// The . - /// The help page sample generator. - public static void SetHelpPageSampleGenerator(this HttpConfiguration config, HelpPageSampleGenerator sampleGenerator) - { - config.Properties.AddOrUpdate( - typeof(HelpPageSampleGenerator), - k => sampleGenerator, - (k, o) => sampleGenerator); - } - - /// - /// Gets the model description generator. - /// - /// The configuration. - /// The - public static ModelDescriptionGenerator GetModelDescriptionGenerator(this HttpConfiguration config) - { - return (ModelDescriptionGenerator)config.Properties.GetOrAdd( - typeof(ModelDescriptionGenerator), - k => InitializeModelDescriptionGenerator(config)); - } - - /// - /// Gets the model that represents an API displayed on the help page. The model is initialized on the first call and cached for subsequent calls. - /// - /// The . - /// The ID. - /// - /// An - /// - public static HelpPageApiModel GetHelpPageApiModel(this HttpConfiguration config, string apiDescriptionId) - { - object model; - string modelId = ApiModelPrefix + apiDescriptionId; - if (!config.Properties.TryGetValue(modelId, out model)) - { - Collection apiDescriptions = config.Services.GetApiExplorer().ApiDescriptions; - ApiDescription apiDescription = apiDescriptions.FirstOrDefault(api => String.Equals(api.GetFriendlyId(), apiDescriptionId, StringComparison.OrdinalIgnoreCase)); - if (apiDescription != null) - { - model = GenerateApiModel(apiDescription, config); - config.Properties.TryAdd(modelId, model); - } - } - - return (HelpPageApiModel)model; - } - - private static HelpPageApiModel GenerateApiModel(ApiDescription apiDescription, HttpConfiguration config) - { - HelpPageApiModel apiModel = new HelpPageApiModel() - { - ApiDescription = apiDescription, - }; - - ModelDescriptionGenerator modelGenerator = config.GetModelDescriptionGenerator(); - HelpPageSampleGenerator sampleGenerator = config.GetHelpPageSampleGenerator(); - GenerateUriParameters(apiModel, modelGenerator); - GenerateRequestModelDescription(apiModel, modelGenerator, sampleGenerator); - GenerateResourceDescription(apiModel, modelGenerator); - GenerateSamples(apiModel, sampleGenerator); - - return apiModel; - } - - private static void GenerateUriParameters(HelpPageApiModel apiModel, ModelDescriptionGenerator modelGenerator) - { - ApiDescription apiDescription = apiModel.ApiDescription; - foreach (ApiParameterDescription apiParameter in apiDescription.ParameterDescriptions) - { - if (apiParameter.Source == ApiParameterSource.FromUri) - { - HttpParameterDescriptor parameterDescriptor = apiParameter.ParameterDescriptor; - Type parameterType = null; - ModelDescription typeDescription = null; - ComplexTypeModelDescription complexTypeDescription = null; - if (parameterDescriptor != null) - { - parameterType = parameterDescriptor.ParameterType; - typeDescription = modelGenerator.GetOrCreateModelDescription(parameterType); - complexTypeDescription = typeDescription as ComplexTypeModelDescription; - } - - if (complexTypeDescription != null) - { - foreach (ParameterDescription uriParameter in complexTypeDescription.Properties) - { - apiModel.UriParameters.Add(uriParameter); - } - } - else if (parameterDescriptor != null) - { - ParameterDescription uriParameter = - AddParameterDescription(apiModel, apiParameter, typeDescription); - - if (!parameterDescriptor.IsOptional) - { - uriParameter.Annotations.Add(new ParameterAnnotation() { Documentation = "Required" }); - } - - object defaultValue = parameterDescriptor.DefaultValue; - if (defaultValue != null) - { - uriParameter.Annotations.Add(new ParameterAnnotation() { Documentation = "Default value is " + Convert.ToString(defaultValue, CultureInfo.InvariantCulture) }); - } - } - else - { - Debug.Assert(parameterDescriptor == null); - - // If parameterDescriptor is null, this is an undeclared route parameter which only occurs - // when source is FromUri. Ignored in request model and among resource parameters but listed - // as a simple string here. - ModelDescription modelDescription = modelGenerator.GetOrCreateModelDescription(typeof(string)); - AddParameterDescription(apiModel, apiParameter, modelDescription); - } - } - } - } - - private static ParameterDescription AddParameterDescription(HelpPageApiModel apiModel, - ApiParameterDescription apiParameter, ModelDescription typeDescription) - { - ParameterDescription parameterDescription = new ParameterDescription - { - Name = apiParameter.Name, - Documentation = apiParameter.Documentation, - TypeDescription = typeDescription, - }; - - apiModel.UriParameters.Add(parameterDescription); - return parameterDescription; - } - - private static void GenerateRequestModelDescription(HelpPageApiModel apiModel, ModelDescriptionGenerator modelGenerator, HelpPageSampleGenerator sampleGenerator) - { - ApiDescription apiDescription = apiModel.ApiDescription; - foreach (ApiParameterDescription apiParameter in apiDescription.ParameterDescriptions) - { - if (apiParameter.Source == ApiParameterSource.FromBody) - { - Type parameterType = apiParameter.ParameterDescriptor.ParameterType; - apiModel.RequestModelDescription = modelGenerator.GetOrCreateModelDescription(parameterType); - apiModel.RequestDocumentation = apiParameter.Documentation; - } - else if (apiParameter.ParameterDescriptor != null && - apiParameter.ParameterDescriptor.ParameterType == typeof(HttpRequestMessage)) - { - Type parameterType = sampleGenerator.ResolveHttpRequestMessageType(apiDescription); - - if (parameterType != null) - { - apiModel.RequestModelDescription = modelGenerator.GetOrCreateModelDescription(parameterType); - } - } - } - } - - private static void GenerateResourceDescription(HelpPageApiModel apiModel, ModelDescriptionGenerator modelGenerator) - { - ResponseDescription response = apiModel.ApiDescription.ResponseDescription; - Type responseType = response.ResponseType ?? response.DeclaredType; - if (responseType != null && responseType != typeof(void)) - { - apiModel.ResourceDescription = modelGenerator.GetOrCreateModelDescription(responseType); - } - } - - [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "The exception is recorded as ErrorMessages.")] - private static void GenerateSamples(HelpPageApiModel apiModel, HelpPageSampleGenerator sampleGenerator) - { - try - { - foreach (var item in sampleGenerator.GetSampleRequests(apiModel.ApiDescription)) - { - apiModel.SampleRequests.Add(item.Key, item.Value); - LogInvalidSampleAsError(apiModel, item.Value); - } - - foreach (var item in sampleGenerator.GetSampleResponses(apiModel.ApiDescription)) - { - apiModel.SampleResponses.Add(item.Key, item.Value); - LogInvalidSampleAsError(apiModel, item.Value); - } - } - catch (Exception e) - { - apiModel.ErrorMessages.Add(String.Format(CultureInfo.CurrentCulture, - "An exception has occurred while generating the sample. Exception message: {0}", - HelpPageSampleGenerator.UnwrapException(e).Message)); - } - } - - private static bool TryGetResourceParameter(ApiDescription apiDescription, HttpConfiguration config, out ApiParameterDescription parameterDescription, out Type resourceType) - { - parameterDescription = apiDescription.ParameterDescriptions.FirstOrDefault( - p => p.Source == ApiParameterSource.FromBody || - (p.ParameterDescriptor != null && p.ParameterDescriptor.ParameterType == typeof(HttpRequestMessage))); - - if (parameterDescription == null) - { - resourceType = null; - return false; - } - - resourceType = parameterDescription.ParameterDescriptor.ParameterType; - - if (resourceType == typeof(HttpRequestMessage)) - { - HelpPageSampleGenerator sampleGenerator = config.GetHelpPageSampleGenerator(); - resourceType = sampleGenerator.ResolveHttpRequestMessageType(apiDescription); - } - - if (resourceType == null) - { - parameterDescription = null; - return false; - } - - return true; - } - - private static ModelDescriptionGenerator InitializeModelDescriptionGenerator(HttpConfiguration config) - { - ModelDescriptionGenerator modelGenerator = new ModelDescriptionGenerator(config); - Collection apis = config.Services.GetApiExplorer().ApiDescriptions; - foreach (ApiDescription api in apis) - { - ApiParameterDescription parameterDescription; - Type parameterType; - if (TryGetResourceParameter(api, config, out parameterDescription, out parameterType)) - { - modelGenerator.GetOrCreateModelDescription(parameterType); - } - } - return modelGenerator; - } - - private static void LogInvalidSampleAsError(HelpPageApiModel apiModel, object sample) - { - InvalidSample invalidSample = sample as InvalidSample; - if (invalidSample != null) - { - apiModel.ErrorMessages.Add(invalidSample.ErrorMessage); - } - } - } -} diff --git a/Browar/Browar/Areas/HelpPage/ModelDescriptions/CollectionModelDescription.cs b/Browar/Browar/Areas/HelpPage/ModelDescriptions/CollectionModelDescription.cs deleted file mode 100644 index ab5ff04..0000000 --- a/Browar/Browar/Areas/HelpPage/ModelDescriptions/CollectionModelDescription.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Browar.Areas.HelpPage.ModelDescriptions -{ - public class CollectionModelDescription : ModelDescription - { - public ModelDescription ElementDescription { get; set; } - } -} \ No newline at end of file diff --git a/Browar/Browar/Areas/HelpPage/ModelDescriptions/ComplexTypeModelDescription.cs b/Browar/Browar/Areas/HelpPage/ModelDescriptions/ComplexTypeModelDescription.cs deleted file mode 100644 index cc4bfa2..0000000 --- a/Browar/Browar/Areas/HelpPage/ModelDescriptions/ComplexTypeModelDescription.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.Collections.ObjectModel; - -namespace Browar.Areas.HelpPage.ModelDescriptions -{ - public class ComplexTypeModelDescription : ModelDescription - { - public ComplexTypeModelDescription() - { - Properties = new Collection(); - } - - public Collection Properties { get; private set; } - } -} \ No newline at end of file diff --git a/Browar/Browar/Areas/HelpPage/ModelDescriptions/DictionaryModelDescription.cs b/Browar/Browar/Areas/HelpPage/ModelDescriptions/DictionaryModelDescription.cs deleted file mode 100644 index ee3a3fb..0000000 --- a/Browar/Browar/Areas/HelpPage/ModelDescriptions/DictionaryModelDescription.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Browar.Areas.HelpPage.ModelDescriptions -{ - public class DictionaryModelDescription : KeyValuePairModelDescription - { - } -} \ No newline at end of file diff --git a/Browar/Browar/Areas/HelpPage/ModelDescriptions/EnumTypeModelDescription.cs b/Browar/Browar/Areas/HelpPage/ModelDescriptions/EnumTypeModelDescription.cs deleted file mode 100644 index 7bb5625..0000000 --- a/Browar/Browar/Areas/HelpPage/ModelDescriptions/EnumTypeModelDescription.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Collections.Generic; -using System.Collections.ObjectModel; - -namespace Browar.Areas.HelpPage.ModelDescriptions -{ - public class EnumTypeModelDescription : ModelDescription - { - public EnumTypeModelDescription() - { - Values = new Collection(); - } - - public Collection Values { get; private set; } - } -} \ No newline at end of file diff --git a/Browar/Browar/Areas/HelpPage/ModelDescriptions/EnumValueDescription.cs b/Browar/Browar/Areas/HelpPage/ModelDescriptions/EnumValueDescription.cs deleted file mode 100644 index d76b9ba..0000000 --- a/Browar/Browar/Areas/HelpPage/ModelDescriptions/EnumValueDescription.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Browar.Areas.HelpPage.ModelDescriptions -{ - public class EnumValueDescription - { - public string Documentation { get; set; } - - public string Name { get; set; } - - public string Value { get; set; } - } -} \ No newline at end of file diff --git a/Browar/Browar/Areas/HelpPage/ModelDescriptions/IModelDocumentationProvider.cs b/Browar/Browar/Areas/HelpPage/ModelDescriptions/IModelDocumentationProvider.cs deleted file mode 100644 index 7085a3c..0000000 --- a/Browar/Browar/Areas/HelpPage/ModelDescriptions/IModelDocumentationProvider.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Reflection; - -namespace Browar.Areas.HelpPage.ModelDescriptions -{ - public interface IModelDocumentationProvider - { - string GetDocumentation(MemberInfo member); - - string GetDocumentation(Type type); - } -} \ No newline at end of file diff --git a/Browar/Browar/Areas/HelpPage/ModelDescriptions/KeyValuePairModelDescription.cs b/Browar/Browar/Areas/HelpPage/ModelDescriptions/KeyValuePairModelDescription.cs deleted file mode 100644 index 5cb49b7..0000000 --- a/Browar/Browar/Areas/HelpPage/ModelDescriptions/KeyValuePairModelDescription.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Browar.Areas.HelpPage.ModelDescriptions -{ - public class KeyValuePairModelDescription : ModelDescription - { - public ModelDescription KeyModelDescription { get; set; } - - public ModelDescription ValueModelDescription { get; set; } - } -} \ No newline at end of file diff --git a/Browar/Browar/Areas/HelpPage/ModelDescriptions/ModelDescription.cs b/Browar/Browar/Areas/HelpPage/ModelDescriptions/ModelDescription.cs deleted file mode 100644 index 4ce8f98..0000000 --- a/Browar/Browar/Areas/HelpPage/ModelDescriptions/ModelDescription.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; - -namespace Browar.Areas.HelpPage.ModelDescriptions -{ - /// - /// Describes a type model. - /// - public abstract class ModelDescription - { - public string Documentation { get; set; } - - public Type ModelType { get; set; } - - public string Name { get; set; } - } -} \ No newline at end of file diff --git a/Browar/Browar/Areas/HelpPage/ModelDescriptions/ModelDescriptionGenerator.cs b/Browar/Browar/Areas/HelpPage/ModelDescriptions/ModelDescriptionGenerator.cs deleted file mode 100644 index 2e5fa09..0000000 --- a/Browar/Browar/Areas/HelpPage/ModelDescriptions/ModelDescriptionGenerator.cs +++ /dev/null @@ -1,451 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.Specialized; -using System.ComponentModel.DataAnnotations; -using System.Globalization; -using System.Reflection; -using System.Runtime.Serialization; -using System.Web.Http; -using System.Web.Http.Description; -using System.Xml.Serialization; -using Newtonsoft.Json; - -namespace Browar.Areas.HelpPage.ModelDescriptions -{ - /// - /// Generates model descriptions for given types. - /// - public class ModelDescriptionGenerator - { - // Modify this to support more data annotation attributes. - private readonly IDictionary> AnnotationTextGenerator = new Dictionary> - { - { typeof(RequiredAttribute), a => "Required" }, - { typeof(RangeAttribute), a => - { - RangeAttribute range = (RangeAttribute)a; - return String.Format(CultureInfo.CurrentCulture, "Range: inclusive between {0} and {1}", range.Minimum, range.Maximum); - } - }, - { typeof(MaxLengthAttribute), a => - { - MaxLengthAttribute maxLength = (MaxLengthAttribute)a; - return String.Format(CultureInfo.CurrentCulture, "Max length: {0}", maxLength.Length); - } - }, - { typeof(MinLengthAttribute), a => - { - MinLengthAttribute minLength = (MinLengthAttribute)a; - return String.Format(CultureInfo.CurrentCulture, "Min length: {0}", minLength.Length); - } - }, - { typeof(StringLengthAttribute), a => - { - StringLengthAttribute strLength = (StringLengthAttribute)a; - return String.Format(CultureInfo.CurrentCulture, "String length: inclusive between {0} and {1}", strLength.MinimumLength, strLength.MaximumLength); - } - }, - { typeof(DataTypeAttribute), a => - { - DataTypeAttribute dataType = (DataTypeAttribute)a; - return String.Format(CultureInfo.CurrentCulture, "Data type: {0}", dataType.CustomDataType ?? dataType.DataType.ToString()); - } - }, - { typeof(RegularExpressionAttribute), a => - { - RegularExpressionAttribute regularExpression = (RegularExpressionAttribute)a; - return String.Format(CultureInfo.CurrentCulture, "Matching regular expression pattern: {0}", regularExpression.Pattern); - } - }, - }; - - // Modify this to add more default documentations. - private readonly IDictionary DefaultTypeDocumentation = new Dictionary - { - { typeof(Int16), "integer" }, - { typeof(Int32), "integer" }, - { typeof(Int64), "integer" }, - { typeof(UInt16), "unsigned integer" }, - { typeof(UInt32), "unsigned integer" }, - { typeof(UInt64), "unsigned integer" }, - { typeof(Byte), "byte" }, - { typeof(Char), "character" }, - { typeof(SByte), "signed byte" }, - { typeof(Uri), "URI" }, - { typeof(Single), "decimal number" }, - { typeof(Double), "decimal number" }, - { typeof(Decimal), "decimal number" }, - { typeof(String), "string" }, - { typeof(Guid), "globally unique identifier" }, - { typeof(TimeSpan), "time interval" }, - { typeof(DateTime), "date" }, - { typeof(DateTimeOffset), "date" }, - { typeof(Boolean), "boolean" }, - }; - - private Lazy _documentationProvider; - - public ModelDescriptionGenerator(HttpConfiguration config) - { - if (config == null) - { - throw new ArgumentNullException("config"); - } - - _documentationProvider = new Lazy(() => config.Services.GetDocumentationProvider() as IModelDocumentationProvider); - GeneratedModels = new Dictionary(StringComparer.OrdinalIgnoreCase); - } - - public Dictionary GeneratedModels { get; private set; } - - private IModelDocumentationProvider DocumentationProvider - { - get - { - return _documentationProvider.Value; - } - } - - public ModelDescription GetOrCreateModelDescription(Type modelType) - { - if (modelType == null) - { - throw new ArgumentNullException("modelType"); - } - - Type underlyingType = Nullable.GetUnderlyingType(modelType); - if (underlyingType != null) - { - modelType = underlyingType; - } - - ModelDescription modelDescription; - string modelName = ModelNameHelper.GetModelName(modelType); - if (GeneratedModels.TryGetValue(modelName, out modelDescription)) - { - if (modelType != modelDescription.ModelType) - { - throw new InvalidOperationException( - String.Format( - CultureInfo.CurrentCulture, - "A model description could not be created. Duplicate model name '{0}' was found for types '{1}' and '{2}'. " + - "Use the [ModelName] attribute to change the model name for at least one of the types so that it has a unique name.", - modelName, - modelDescription.ModelType.FullName, - modelType.FullName)); - } - - return modelDescription; - } - - if (DefaultTypeDocumentation.ContainsKey(modelType)) - { - return GenerateSimpleTypeModelDescription(modelType); - } - - if (modelType.IsEnum) - { - return GenerateEnumTypeModelDescription(modelType); - } - - if (modelType.IsGenericType) - { - Type[] genericArguments = modelType.GetGenericArguments(); - - if (genericArguments.Length == 1) - { - Type enumerableType = typeof(IEnumerable<>).MakeGenericType(genericArguments); - if (enumerableType.IsAssignableFrom(modelType)) - { - return GenerateCollectionModelDescription(modelType, genericArguments[0]); - } - } - if (genericArguments.Length == 2) - { - Type dictionaryType = typeof(IDictionary<,>).MakeGenericType(genericArguments); - if (dictionaryType.IsAssignableFrom(modelType)) - { - return GenerateDictionaryModelDescription(modelType, genericArguments[0], genericArguments[1]); - } - - Type keyValuePairType = typeof(KeyValuePair<,>).MakeGenericType(genericArguments); - if (keyValuePairType.IsAssignableFrom(modelType)) - { - return GenerateKeyValuePairModelDescription(modelType, genericArguments[0], genericArguments[1]); - } - } - } - - if (modelType.IsArray) - { - Type elementType = modelType.GetElementType(); - return GenerateCollectionModelDescription(modelType, elementType); - } - - if (modelType == typeof(NameValueCollection)) - { - return GenerateDictionaryModelDescription(modelType, typeof(string), typeof(string)); - } - - if (typeof(IDictionary).IsAssignableFrom(modelType)) - { - return GenerateDictionaryModelDescription(modelType, typeof(object), typeof(object)); - } - - if (typeof(IEnumerable).IsAssignableFrom(modelType)) - { - return GenerateCollectionModelDescription(modelType, typeof(object)); - } - - return GenerateComplexTypeModelDescription(modelType); - } - - // Change this to provide different name for the member. - private static string GetMemberName(MemberInfo member, bool hasDataContractAttribute) - { - JsonPropertyAttribute jsonProperty = member.GetCustomAttribute(); - if (jsonProperty != null && !String.IsNullOrEmpty(jsonProperty.PropertyName)) - { - return jsonProperty.PropertyName; - } - - if (hasDataContractAttribute) - { - DataMemberAttribute dataMember = member.GetCustomAttribute(); - if (dataMember != null && !String.IsNullOrEmpty(dataMember.Name)) - { - return dataMember.Name; - } - } - - return member.Name; - } - - private static bool ShouldDisplayMember(MemberInfo member, bool hasDataContractAttribute) - { - JsonIgnoreAttribute jsonIgnore = member.GetCustomAttribute(); - XmlIgnoreAttribute xmlIgnore = member.GetCustomAttribute(); - IgnoreDataMemberAttribute ignoreDataMember = member.GetCustomAttribute(); - NonSerializedAttribute nonSerialized = member.GetCustomAttribute(); - ApiExplorerSettingsAttribute apiExplorerSetting = member.GetCustomAttribute(); - - bool hasMemberAttribute = member.DeclaringType.IsEnum ? - member.GetCustomAttribute() != null : - member.GetCustomAttribute() != null; - - // Display member only if all the followings are true: - // no JsonIgnoreAttribute - // no XmlIgnoreAttribute - // no IgnoreDataMemberAttribute - // no NonSerializedAttribute - // no ApiExplorerSettingsAttribute with IgnoreApi set to true - // no DataContractAttribute without DataMemberAttribute or EnumMemberAttribute - return jsonIgnore == null && - xmlIgnore == null && - ignoreDataMember == null && - nonSerialized == null && - (apiExplorerSetting == null || !apiExplorerSetting.IgnoreApi) && - (!hasDataContractAttribute || hasMemberAttribute); - } - - private string CreateDefaultDocumentation(Type type) - { - string documentation; - if (DefaultTypeDocumentation.TryGetValue(type, out documentation)) - { - return documentation; - } - if (DocumentationProvider != null) - { - documentation = DocumentationProvider.GetDocumentation(type); - } - - return documentation; - } - - private void GenerateAnnotations(MemberInfo property, ParameterDescription propertyModel) - { - List annotations = new List(); - - IEnumerable attributes = property.GetCustomAttributes(); - foreach (Attribute attribute in attributes) - { - Func textGenerator; - if (AnnotationTextGenerator.TryGetValue(attribute.GetType(), out textGenerator)) - { - annotations.Add( - new ParameterAnnotation - { - AnnotationAttribute = attribute, - Documentation = textGenerator(attribute) - }); - } - } - - // Rearrange the annotations - annotations.Sort((x, y) => - { - // Special-case RequiredAttribute so that it shows up on top - if (x.AnnotationAttribute is RequiredAttribute) - { - return -1; - } - if (y.AnnotationAttribute is RequiredAttribute) - { - return 1; - } - - // Sort the rest based on alphabetic order of the documentation - return String.Compare(x.Documentation, y.Documentation, StringComparison.OrdinalIgnoreCase); - }); - - foreach (ParameterAnnotation annotation in annotations) - { - propertyModel.Annotations.Add(annotation); - } - } - - private CollectionModelDescription GenerateCollectionModelDescription(Type modelType, Type elementType) - { - ModelDescription collectionModelDescription = GetOrCreateModelDescription(elementType); - if (collectionModelDescription != null) - { - return new CollectionModelDescription - { - Name = ModelNameHelper.GetModelName(modelType), - ModelType = modelType, - ElementDescription = collectionModelDescription - }; - } - - return null; - } - - private ModelDescription GenerateComplexTypeModelDescription(Type modelType) - { - ComplexTypeModelDescription complexModelDescription = new ComplexTypeModelDescription - { - Name = ModelNameHelper.GetModelName(modelType), - ModelType = modelType, - Documentation = CreateDefaultDocumentation(modelType) - }; - - GeneratedModels.Add(complexModelDescription.Name, complexModelDescription); - bool hasDataContractAttribute = modelType.GetCustomAttribute() != null; - PropertyInfo[] properties = modelType.GetProperties(BindingFlags.Public | BindingFlags.Instance); - foreach (PropertyInfo property in properties) - { - if (ShouldDisplayMember(property, hasDataContractAttribute)) - { - ParameterDescription propertyModel = new ParameterDescription - { - Name = GetMemberName(property, hasDataContractAttribute) - }; - - if (DocumentationProvider != null) - { - propertyModel.Documentation = DocumentationProvider.GetDocumentation(property); - } - - GenerateAnnotations(property, propertyModel); - complexModelDescription.Properties.Add(propertyModel); - propertyModel.TypeDescription = GetOrCreateModelDescription(property.PropertyType); - } - } - - FieldInfo[] fields = modelType.GetFields(BindingFlags.Public | BindingFlags.Instance); - foreach (FieldInfo field in fields) - { - if (ShouldDisplayMember(field, hasDataContractAttribute)) - { - ParameterDescription propertyModel = new ParameterDescription - { - Name = GetMemberName(field, hasDataContractAttribute) - }; - - if (DocumentationProvider != null) - { - propertyModel.Documentation = DocumentationProvider.GetDocumentation(field); - } - - complexModelDescription.Properties.Add(propertyModel); - propertyModel.TypeDescription = GetOrCreateModelDescription(field.FieldType); - } - } - - return complexModelDescription; - } - - private DictionaryModelDescription GenerateDictionaryModelDescription(Type modelType, Type keyType, Type valueType) - { - ModelDescription keyModelDescription = GetOrCreateModelDescription(keyType); - ModelDescription valueModelDescription = GetOrCreateModelDescription(valueType); - - return new DictionaryModelDescription - { - Name = ModelNameHelper.GetModelName(modelType), - ModelType = modelType, - KeyModelDescription = keyModelDescription, - ValueModelDescription = valueModelDescription - }; - } - - private EnumTypeModelDescription GenerateEnumTypeModelDescription(Type modelType) - { - EnumTypeModelDescription enumDescription = new EnumTypeModelDescription - { - Name = ModelNameHelper.GetModelName(modelType), - ModelType = modelType, - Documentation = CreateDefaultDocumentation(modelType) - }; - bool hasDataContractAttribute = modelType.GetCustomAttribute() != null; - foreach (FieldInfo field in modelType.GetFields(BindingFlags.Public | BindingFlags.Static)) - { - if (ShouldDisplayMember(field, hasDataContractAttribute)) - { - EnumValueDescription enumValue = new EnumValueDescription - { - Name = field.Name, - Value = field.GetRawConstantValue().ToString() - }; - if (DocumentationProvider != null) - { - enumValue.Documentation = DocumentationProvider.GetDocumentation(field); - } - enumDescription.Values.Add(enumValue); - } - } - GeneratedModels.Add(enumDescription.Name, enumDescription); - - return enumDescription; - } - - private KeyValuePairModelDescription GenerateKeyValuePairModelDescription(Type modelType, Type keyType, Type valueType) - { - ModelDescription keyModelDescription = GetOrCreateModelDescription(keyType); - ModelDescription valueModelDescription = GetOrCreateModelDescription(valueType); - - return new KeyValuePairModelDescription - { - Name = ModelNameHelper.GetModelName(modelType), - ModelType = modelType, - KeyModelDescription = keyModelDescription, - ValueModelDescription = valueModelDescription - }; - } - - private ModelDescription GenerateSimpleTypeModelDescription(Type modelType) - { - SimpleTypeModelDescription simpleModelDescription = new SimpleTypeModelDescription - { - Name = ModelNameHelper.GetModelName(modelType), - ModelType = modelType, - Documentation = CreateDefaultDocumentation(modelType) - }; - GeneratedModels.Add(simpleModelDescription.Name, simpleModelDescription); - - return simpleModelDescription; - } - } -} \ No newline at end of file diff --git a/Browar/Browar/Areas/HelpPage/ModelDescriptions/ModelNameAttribute.cs b/Browar/Browar/Areas/HelpPage/ModelDescriptions/ModelNameAttribute.cs deleted file mode 100644 index fb2b3d8..0000000 --- a/Browar/Browar/Areas/HelpPage/ModelDescriptions/ModelNameAttribute.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; - -namespace Browar.Areas.HelpPage.ModelDescriptions -{ - /// - /// Use this attribute to change the name of the generated for a type. - /// - [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum, AllowMultiple = false, Inherited = false)] - public sealed class ModelNameAttribute : Attribute - { - public ModelNameAttribute(string name) - { - Name = name; - } - - public string Name { get; private set; } - } -} \ No newline at end of file diff --git a/Browar/Browar/Areas/HelpPage/ModelDescriptions/ModelNameHelper.cs b/Browar/Browar/Areas/HelpPage/ModelDescriptions/ModelNameHelper.cs deleted file mode 100644 index 74dd609..0000000 --- a/Browar/Browar/Areas/HelpPage/ModelDescriptions/ModelNameHelper.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using System.Globalization; -using System.Linq; -using System.Reflection; - -namespace Browar.Areas.HelpPage.ModelDescriptions -{ - internal static class ModelNameHelper - { - // Modify this to provide custom model name mapping. - public static string GetModelName(Type type) - { - ModelNameAttribute modelNameAttribute = type.GetCustomAttribute(); - if (modelNameAttribute != null && !String.IsNullOrEmpty(modelNameAttribute.Name)) - { - return modelNameAttribute.Name; - } - - string modelName = type.Name; - if (type.IsGenericType) - { - // Format the generic type name to something like: GenericOfAgurment1AndArgument2 - Type genericType = type.GetGenericTypeDefinition(); - Type[] genericArguments = type.GetGenericArguments(); - string genericTypeName = genericType.Name; - - // Trim the generic parameter counts from the name - genericTypeName = genericTypeName.Substring(0, genericTypeName.IndexOf('`')); - string[] argumentTypeNames = genericArguments.Select(t => GetModelName(t)).ToArray(); - modelName = String.Format(CultureInfo.InvariantCulture, "{0}Of{1}", genericTypeName, String.Join("And", argumentTypeNames)); - } - - return modelName; - } - } -} \ No newline at end of file diff --git a/Browar/Browar/Areas/HelpPage/ModelDescriptions/ParameterAnnotation.cs b/Browar/Browar/Areas/HelpPage/ModelDescriptions/ParameterAnnotation.cs deleted file mode 100644 index 3158e5a..0000000 --- a/Browar/Browar/Areas/HelpPage/ModelDescriptions/ParameterAnnotation.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; - -namespace Browar.Areas.HelpPage.ModelDescriptions -{ - public class ParameterAnnotation - { - public Attribute AnnotationAttribute { get; set; } - - public string Documentation { get; set; } - } -} \ No newline at end of file diff --git a/Browar/Browar/Areas/HelpPage/ModelDescriptions/ParameterDescription.cs b/Browar/Browar/Areas/HelpPage/ModelDescriptions/ParameterDescription.cs deleted file mode 100644 index 8efe66c..0000000 --- a/Browar/Browar/Areas/HelpPage/ModelDescriptions/ParameterDescription.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.Collections.Generic; -using System.Collections.ObjectModel; - -namespace Browar.Areas.HelpPage.ModelDescriptions -{ - public class ParameterDescription - { - public ParameterDescription() - { - Annotations = new Collection(); - } - - public Collection Annotations { get; private set; } - - public string Documentation { get; set; } - - public string Name { get; set; } - - public ModelDescription TypeDescription { get; set; } - } -} \ No newline at end of file diff --git a/Browar/Browar/Areas/HelpPage/ModelDescriptions/SimpleTypeModelDescription.cs b/Browar/Browar/Areas/HelpPage/ModelDescriptions/SimpleTypeModelDescription.cs deleted file mode 100644 index d9d3d61..0000000 --- a/Browar/Browar/Areas/HelpPage/ModelDescriptions/SimpleTypeModelDescription.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Browar.Areas.HelpPage.ModelDescriptions -{ - public class SimpleTypeModelDescription : ModelDescription - { - } -} \ No newline at end of file diff --git a/Browar/Browar/Areas/HelpPage/Models/HelpPageApiModel.cs b/Browar/Browar/Areas/HelpPage/Models/HelpPageApiModel.cs deleted file mode 100644 index 5286aa4..0000000 --- a/Browar/Browar/Areas/HelpPage/Models/HelpPageApiModel.cs +++ /dev/null @@ -1,108 +0,0 @@ -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Net.Http.Headers; -using System.Web.Http.Description; -using Browar.Areas.HelpPage.ModelDescriptions; - -namespace Browar.Areas.HelpPage.Models -{ - /// - /// The model that represents an API displayed on the help page. - /// - public class HelpPageApiModel - { - /// - /// Initializes a new instance of the class. - /// - public HelpPageApiModel() - { - UriParameters = new Collection(); - SampleRequests = new Dictionary(); - SampleResponses = new Dictionary(); - ErrorMessages = new Collection(); - } - - /// - /// Gets or sets the that describes the API. - /// - public ApiDescription ApiDescription { get; set; } - - /// - /// Gets or sets the collection that describes the URI parameters for the API. - /// - public Collection UriParameters { get; private set; } - - /// - /// Gets or sets the documentation for the request. - /// - public string RequestDocumentation { get; set; } - - /// - /// Gets or sets the that describes the request body. - /// - public ModelDescription RequestModelDescription { get; set; } - - /// - /// Gets the request body parameter descriptions. - /// - public IList RequestBodyParameters - { - get - { - return GetParameterDescriptions(RequestModelDescription); - } - } - - /// - /// Gets or sets the that describes the resource. - /// - public ModelDescription ResourceDescription { get; set; } - - /// - /// Gets the resource property descriptions. - /// - public IList ResourceProperties - { - get - { - return GetParameterDescriptions(ResourceDescription); - } - } - - /// - /// Gets the sample requests associated with the API. - /// - public IDictionary SampleRequests { get; private set; } - - /// - /// Gets the sample responses associated with the API. - /// - public IDictionary SampleResponses { get; private set; } - - /// - /// Gets the error messages associated with this model. - /// - public Collection ErrorMessages { get; private set; } - - private static IList GetParameterDescriptions(ModelDescription modelDescription) - { - ComplexTypeModelDescription complexTypeModelDescription = modelDescription as ComplexTypeModelDescription; - if (complexTypeModelDescription != null) - { - return complexTypeModelDescription.Properties; - } - - CollectionModelDescription collectionModelDescription = modelDescription as CollectionModelDescription; - if (collectionModelDescription != null) - { - complexTypeModelDescription = collectionModelDescription.ElementDescription as ComplexTypeModelDescription; - if (complexTypeModelDescription != null) - { - return complexTypeModelDescription.Properties; - } - } - - return null; - } - } -} \ No newline at end of file diff --git a/Browar/Browar/Areas/HelpPage/SampleGeneration/HelpPageSampleGenerator.cs b/Browar/Browar/Areas/HelpPage/SampleGeneration/HelpPageSampleGenerator.cs deleted file mode 100644 index 06c687d..0000000 --- a/Browar/Browar/Areas/HelpPage/SampleGeneration/HelpPageSampleGenerator.cs +++ /dev/null @@ -1,444 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.ComponentModel; -using System.Diagnostics.CodeAnalysis; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Net.Http; -using System.Net.Http.Formatting; -using System.Net.Http.Headers; -using System.Web.Http.Description; -using System.Xml.Linq; -using Newtonsoft.Json; - -namespace Browar.Areas.HelpPage -{ - /// - /// This class will generate the samples for the help page. - /// - public class HelpPageSampleGenerator - { - /// - /// Initializes a new instance of the class. - /// - public HelpPageSampleGenerator() - { - ActualHttpMessageTypes = new Dictionary(); - ActionSamples = new Dictionary(); - SampleObjects = new Dictionary(); - SampleObjectFactories = new List> - { - DefaultSampleObjectFactory, - }; - } - - /// - /// Gets CLR types that are used as the content of or . - /// - public IDictionary ActualHttpMessageTypes { get; internal set; } - - /// - /// Gets the objects that are used directly as samples for certain actions. - /// - public IDictionary ActionSamples { get; internal set; } - - /// - /// Gets the objects that are serialized as samples by the supported formatters. - /// - public IDictionary SampleObjects { get; internal set; } - - /// - /// Gets factories for the objects that the supported formatters will serialize as samples. Processed in order, - /// stopping when the factory successfully returns a non- object. - /// - /// - /// Collection includes just initially. Use - /// SampleObjectFactories.Insert(0, func) to provide an override and - /// SampleObjectFactories.Add(func) to provide a fallback. - [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", - Justification = "This is an appropriate nesting of generic types")] - public IList> SampleObjectFactories { get; private set; } - - /// - /// Gets the request body samples for a given . - /// - /// The . - /// The samples keyed by media type. - public IDictionary GetSampleRequests(ApiDescription api) - { - return GetSample(api, SampleDirection.Request); - } - - /// - /// Gets the response body samples for a given . - /// - /// The . - /// The samples keyed by media type. - public IDictionary GetSampleResponses(ApiDescription api) - { - return GetSample(api, SampleDirection.Response); - } - - /// - /// Gets the request or response body samples. - /// - /// The . - /// The value indicating whether the sample is for a request or for a response. - /// The samples keyed by media type. - public virtual IDictionary GetSample(ApiDescription api, SampleDirection sampleDirection) - { - if (api == null) - { - throw new ArgumentNullException("api"); - } - string controllerName = api.ActionDescriptor.ControllerDescriptor.ControllerName; - string actionName = api.ActionDescriptor.ActionName; - IEnumerable parameterNames = api.ParameterDescriptions.Select(p => p.Name); - Collection formatters; - Type type = ResolveType(api, controllerName, actionName, parameterNames, sampleDirection, out formatters); - var samples = new Dictionary(); - - // Use the samples provided directly for actions - var actionSamples = GetAllActionSamples(controllerName, actionName, parameterNames, sampleDirection); - foreach (var actionSample in actionSamples) - { - samples.Add(actionSample.Key.MediaType, WrapSampleIfString(actionSample.Value)); - } - - // Do the sample generation based on formatters only if an action doesn't return an HttpResponseMessage. - // Here we cannot rely on formatters because we don't know what's in the HttpResponseMessage, it might not even use formatters. - if (type != null && !typeof(HttpResponseMessage).IsAssignableFrom(type)) - { - object sampleObject = GetSampleObject(type); - foreach (var formatter in formatters) - { - foreach (MediaTypeHeaderValue mediaType in formatter.SupportedMediaTypes) - { - if (!samples.ContainsKey(mediaType)) - { - object sample = GetActionSample(controllerName, actionName, parameterNames, type, formatter, mediaType, sampleDirection); - - // If no sample found, try generate sample using formatter and sample object - if (sample == null && sampleObject != null) - { - sample = WriteSampleObjectUsingFormatter(formatter, sampleObject, type, mediaType); - } - - samples.Add(mediaType, WrapSampleIfString(sample)); - } - } - } - } - - return samples; - } - - /// - /// Search for samples that are provided directly through . - /// - /// Name of the controller. - /// Name of the action. - /// The parameter names. - /// The CLR type. - /// The formatter. - /// The media type. - /// The value indicating whether the sample is for a request or for a response. - /// The sample that matches the parameters. - public virtual object GetActionSample(string controllerName, string actionName, IEnumerable parameterNames, Type type, MediaTypeFormatter formatter, MediaTypeHeaderValue mediaType, SampleDirection sampleDirection) - { - object sample; - - // First, try to get the sample provided for the specified mediaType, sampleDirection, controllerName, actionName and parameterNames. - // If not found, try to get the sample provided for the specified mediaType, sampleDirection, controllerName and actionName regardless of the parameterNames. - // If still not found, try to get the sample provided for the specified mediaType and type. - // Finally, try to get the sample provided for the specified mediaType. - if (ActionSamples.TryGetValue(new HelpPageSampleKey(mediaType, sampleDirection, controllerName, actionName, parameterNames), out sample) || - ActionSamples.TryGetValue(new HelpPageSampleKey(mediaType, sampleDirection, controllerName, actionName, new[] { "*" }), out sample) || - ActionSamples.TryGetValue(new HelpPageSampleKey(mediaType, type), out sample) || - ActionSamples.TryGetValue(new HelpPageSampleKey(mediaType), out sample)) - { - return sample; - } - - return null; - } - - /// - /// Gets the sample object that will be serialized by the formatters. - /// First, it will look at the . If no sample object is found, it will try to create - /// one using (which wraps an ) and other - /// factories in . - /// - /// The type. - /// The sample object. - [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", - Justification = "Even if all items in SampleObjectFactories throw, problem will be visible as missing sample.")] - public virtual object GetSampleObject(Type type) - { - object sampleObject; - - if (!SampleObjects.TryGetValue(type, out sampleObject)) - { - // No specific object available, try our factories. - foreach (Func factory in SampleObjectFactories) - { - if (factory == null) - { - continue; - } - - try - { - sampleObject = factory(this, type); - if (sampleObject != null) - { - break; - } - } - catch - { - // Ignore any problems encountered in the factory; go on to the next one (if any). - } - } - } - - return sampleObject; - } - - /// - /// Resolves the actual type of passed to the in an action. - /// - /// The . - /// The type. - public virtual Type ResolveHttpRequestMessageType(ApiDescription api) - { - string controllerName = api.ActionDescriptor.ControllerDescriptor.ControllerName; - string actionName = api.ActionDescriptor.ActionName; - IEnumerable parameterNames = api.ParameterDescriptions.Select(p => p.Name); - Collection formatters; - return ResolveType(api, controllerName, actionName, parameterNames, SampleDirection.Request, out formatters); - } - - /// - /// Resolves the type of the action parameter or return value when or is used. - /// - /// The . - /// Name of the controller. - /// Name of the action. - /// The parameter names. - /// The value indicating whether the sample is for a request or a response. - /// The formatters. - [SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", Justification = "This is only used in advanced scenarios.")] - public virtual Type ResolveType(ApiDescription api, string controllerName, string actionName, IEnumerable parameterNames, SampleDirection sampleDirection, out Collection formatters) - { - if (!Enum.IsDefined(typeof(SampleDirection), sampleDirection)) - { - throw new InvalidEnumArgumentException("sampleDirection", (int)sampleDirection, typeof(SampleDirection)); - } - if (api == null) - { - throw new ArgumentNullException("api"); - } - Type type; - if (ActualHttpMessageTypes.TryGetValue(new HelpPageSampleKey(sampleDirection, controllerName, actionName, parameterNames), out type) || - ActualHttpMessageTypes.TryGetValue(new HelpPageSampleKey(sampleDirection, controllerName, actionName, new[] { "*" }), out type)) - { - // Re-compute the supported formatters based on type - Collection newFormatters = new Collection(); - foreach (var formatter in api.ActionDescriptor.Configuration.Formatters) - { - if (IsFormatSupported(sampleDirection, formatter, type)) - { - newFormatters.Add(formatter); - } - } - formatters = newFormatters; - } - else - { - switch (sampleDirection) - { - case SampleDirection.Request: - ApiParameterDescription requestBodyParameter = api.ParameterDescriptions.FirstOrDefault(p => p.Source == ApiParameterSource.FromBody); - type = requestBodyParameter == null ? null : requestBodyParameter.ParameterDescriptor.ParameterType; - formatters = api.SupportedRequestBodyFormatters; - break; - case SampleDirection.Response: - default: - type = api.ResponseDescription.ResponseType ?? api.ResponseDescription.DeclaredType; - formatters = api.SupportedResponseFormatters; - break; - } - } - - return type; - } - - /// - /// Writes the sample object using formatter. - /// - /// The formatter. - /// The value. - /// The type. - /// Type of the media. - /// - [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "The exception is recorded as InvalidSample.")] - public virtual object WriteSampleObjectUsingFormatter(MediaTypeFormatter formatter, object value, Type type, MediaTypeHeaderValue mediaType) - { - if (formatter == null) - { - throw new ArgumentNullException("formatter"); - } - if (mediaType == null) - { - throw new ArgumentNullException("mediaType"); - } - - object sample = String.Empty; - MemoryStream ms = null; - HttpContent content = null; - try - { - if (formatter.CanWriteType(type)) - { - ms = new MemoryStream(); - content = new ObjectContent(type, value, formatter, mediaType); - formatter.WriteToStreamAsync(type, value, ms, content, null).Wait(); - ms.Position = 0; - StreamReader reader = new StreamReader(ms); - string serializedSampleString = reader.ReadToEnd(); - if (mediaType.MediaType.ToUpperInvariant().Contains("XML")) - { - serializedSampleString = TryFormatXml(serializedSampleString); - } - else if (mediaType.MediaType.ToUpperInvariant().Contains("JSON")) - { - serializedSampleString = TryFormatJson(serializedSampleString); - } - - sample = new TextSample(serializedSampleString); - } - else - { - sample = new InvalidSample(String.Format( - CultureInfo.CurrentCulture, - "Failed to generate the sample for media type '{0}'. Cannot use formatter '{1}' to write type '{2}'.", - mediaType, - formatter.GetType().Name, - type.Name)); - } - } - catch (Exception e) - { - sample = new InvalidSample(String.Format( - CultureInfo.CurrentCulture, - "An exception has occurred while using the formatter '{0}' to generate sample for media type '{1}'. Exception message: {2}", - formatter.GetType().Name, - mediaType.MediaType, - UnwrapException(e).Message)); - } - finally - { - if (ms != null) - { - ms.Dispose(); - } - if (content != null) - { - content.Dispose(); - } - } - - return sample; - } - - internal static Exception UnwrapException(Exception exception) - { - AggregateException aggregateException = exception as AggregateException; - if (aggregateException != null) - { - return aggregateException.Flatten().InnerException; - } - return exception; - } - - // Default factory for sample objects - private static object DefaultSampleObjectFactory(HelpPageSampleGenerator sampleGenerator, Type type) - { - // Try to create a default sample object - ObjectGenerator objectGenerator = new ObjectGenerator(); - return objectGenerator.GenerateObject(type); - } - - [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Handling the failure by returning the original string.")] - private static string TryFormatJson(string str) - { - try - { - object parsedJson = JsonConvert.DeserializeObject(str); - return JsonConvert.SerializeObject(parsedJson, Formatting.Indented); - } - catch - { - // can't parse JSON, return the original string - return str; - } - } - - [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Handling the failure by returning the original string.")] - private static string TryFormatXml(string str) - { - try - { - XDocument xml = XDocument.Parse(str); - return xml.ToString(); - } - catch - { - // can't parse XML, return the original string - return str; - } - } - - private static bool IsFormatSupported(SampleDirection sampleDirection, MediaTypeFormatter formatter, Type type) - { - switch (sampleDirection) - { - case SampleDirection.Request: - return formatter.CanReadType(type); - case SampleDirection.Response: - return formatter.CanWriteType(type); - } - return false; - } - - private IEnumerable> GetAllActionSamples(string controllerName, string actionName, IEnumerable parameterNames, SampleDirection sampleDirection) - { - HashSet parameterNamesSet = new HashSet(parameterNames, StringComparer.OrdinalIgnoreCase); - foreach (var sample in ActionSamples) - { - HelpPageSampleKey sampleKey = sample.Key; - if (String.Equals(controllerName, sampleKey.ControllerName, StringComparison.OrdinalIgnoreCase) && - String.Equals(actionName, sampleKey.ActionName, StringComparison.OrdinalIgnoreCase) && - (sampleKey.ParameterNames.SetEquals(new[] { "*" }) || parameterNamesSet.SetEquals(sampleKey.ParameterNames)) && - sampleDirection == sampleKey.SampleDirection) - { - yield return sample; - } - } - } - - private static object WrapSampleIfString(object sample) - { - string stringSample = sample as string; - if (stringSample != null) - { - return new TextSample(stringSample); - } - - return sample; - } - } -} \ No newline at end of file diff --git a/Browar/Browar/Areas/HelpPage/SampleGeneration/HelpPageSampleKey.cs b/Browar/Browar/Areas/HelpPage/SampleGeneration/HelpPageSampleKey.cs deleted file mode 100644 index 5d7954e..0000000 --- a/Browar/Browar/Areas/HelpPage/SampleGeneration/HelpPageSampleKey.cs +++ /dev/null @@ -1,172 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Net.Http.Headers; - -namespace Browar.Areas.HelpPage -{ - /// - /// This is used to identify the place where the sample should be applied. - /// - public class HelpPageSampleKey - { - /// - /// Creates a new based on media type. - /// - /// The media type. - public HelpPageSampleKey(MediaTypeHeaderValue mediaType) - { - if (mediaType == null) - { - throw new ArgumentNullException("mediaType"); - } - - ActionName = String.Empty; - ControllerName = String.Empty; - MediaType = mediaType; - ParameterNames = new HashSet(StringComparer.OrdinalIgnoreCase); - } - - /// - /// Creates a new based on media type and CLR type. - /// - /// The media type. - /// The CLR type. - public HelpPageSampleKey(MediaTypeHeaderValue mediaType, Type type) - : this(mediaType) - { - if (type == null) - { - throw new ArgumentNullException("type"); - } - - ParameterType = type; - } - - /// - /// Creates a new based on , controller name, action name and parameter names. - /// - /// The . - /// Name of the controller. - /// Name of the action. - /// The parameter names. - public HelpPageSampleKey(SampleDirection sampleDirection, string controllerName, string actionName, IEnumerable parameterNames) - { - if (!Enum.IsDefined(typeof(SampleDirection), sampleDirection)) - { - throw new InvalidEnumArgumentException("sampleDirection", (int)sampleDirection, typeof(SampleDirection)); - } - if (controllerName == null) - { - throw new ArgumentNullException("controllerName"); - } - if (actionName == null) - { - throw new ArgumentNullException("actionName"); - } - if (parameterNames == null) - { - throw new ArgumentNullException("parameterNames"); - } - - ControllerName = controllerName; - ActionName = actionName; - ParameterNames = new HashSet(parameterNames, StringComparer.OrdinalIgnoreCase); - SampleDirection = sampleDirection; - } - - /// - /// Creates a new based on media type, , controller name, action name and parameter names. - /// - /// The media type. - /// The . - /// Name of the controller. - /// Name of the action. - /// The parameter names. - public HelpPageSampleKey(MediaTypeHeaderValue mediaType, SampleDirection sampleDirection, string controllerName, string actionName, IEnumerable parameterNames) - : this(sampleDirection, controllerName, actionName, parameterNames) - { - if (mediaType == null) - { - throw new ArgumentNullException("mediaType"); - } - - MediaType = mediaType; - } - - /// - /// Gets the name of the controller. - /// - /// - /// The name of the controller. - /// - public string ControllerName { get; private set; } - - /// - /// Gets the name of the action. - /// - /// - /// The name of the action. - /// - public string ActionName { get; private set; } - - /// - /// Gets the media type. - /// - /// - /// The media type. - /// - public MediaTypeHeaderValue MediaType { get; private set; } - - /// - /// Gets the parameter names. - /// - public HashSet ParameterNames { get; private set; } - - public Type ParameterType { get; private set; } - - /// - /// Gets the . - /// - public SampleDirection? SampleDirection { get; private set; } - - public override bool Equals(object obj) - { - HelpPageSampleKey otherKey = obj as HelpPageSampleKey; - if (otherKey == null) - { - return false; - } - - return String.Equals(ControllerName, otherKey.ControllerName, StringComparison.OrdinalIgnoreCase) && - String.Equals(ActionName, otherKey.ActionName, StringComparison.OrdinalIgnoreCase) && - (MediaType == otherKey.MediaType || (MediaType != null && MediaType.Equals(otherKey.MediaType))) && - ParameterType == otherKey.ParameterType && - SampleDirection == otherKey.SampleDirection && - ParameterNames.SetEquals(otherKey.ParameterNames); - } - - public override int GetHashCode() - { - int hashCode = ControllerName.ToUpperInvariant().GetHashCode() ^ ActionName.ToUpperInvariant().GetHashCode(); - if (MediaType != null) - { - hashCode ^= MediaType.GetHashCode(); - } - if (SampleDirection != null) - { - hashCode ^= SampleDirection.GetHashCode(); - } - if (ParameterType != null) - { - hashCode ^= ParameterType.GetHashCode(); - } - foreach (string parameterName in ParameterNames) - { - hashCode ^= parameterName.ToUpperInvariant().GetHashCode(); - } - - return hashCode; - } - } -} diff --git a/Browar/Browar/Areas/HelpPage/SampleGeneration/ImageSample.cs b/Browar/Browar/Areas/HelpPage/SampleGeneration/ImageSample.cs deleted file mode 100644 index cf345a2..0000000 --- a/Browar/Browar/Areas/HelpPage/SampleGeneration/ImageSample.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; - -namespace Browar.Areas.HelpPage -{ - /// - /// This represents an image sample on the help page. There's a display template named ImageSample associated with this class. - /// - public class ImageSample - { - /// - /// Initializes a new instance of the class. - /// - /// The URL of an image. - public ImageSample(string src) - { - if (src == null) - { - throw new ArgumentNullException("src"); - } - Src = src; - } - - public string Src { get; private set; } - - public override bool Equals(object obj) - { - ImageSample other = obj as ImageSample; - return other != null && Src == other.Src; - } - - public override int GetHashCode() - { - return Src.GetHashCode(); - } - - public override string ToString() - { - return Src; - } - } -} \ No newline at end of file diff --git a/Browar/Browar/Areas/HelpPage/SampleGeneration/InvalidSample.cs b/Browar/Browar/Areas/HelpPage/SampleGeneration/InvalidSample.cs deleted file mode 100644 index a27d94c..0000000 --- a/Browar/Browar/Areas/HelpPage/SampleGeneration/InvalidSample.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; - -namespace Browar.Areas.HelpPage -{ - /// - /// This represents an invalid sample on the help page. There's a display template named InvalidSample associated with this class. - /// - public class InvalidSample - { - public InvalidSample(string errorMessage) - { - if (errorMessage == null) - { - throw new ArgumentNullException("errorMessage"); - } - ErrorMessage = errorMessage; - } - - public string ErrorMessage { get; private set; } - - public override bool Equals(object obj) - { - InvalidSample other = obj as InvalidSample; - return other != null && ErrorMessage == other.ErrorMessage; - } - - public override int GetHashCode() - { - return ErrorMessage.GetHashCode(); - } - - public override string ToString() - { - return ErrorMessage; - } - } -} \ No newline at end of file diff --git a/Browar/Browar/Areas/HelpPage/SampleGeneration/ObjectGenerator.cs b/Browar/Browar/Areas/HelpPage/SampleGeneration/ObjectGenerator.cs deleted file mode 100644 index 33f6e20..0000000 --- a/Browar/Browar/Areas/HelpPage/SampleGeneration/ObjectGenerator.cs +++ /dev/null @@ -1,456 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Globalization; -using System.Linq; -using System.Reflection; - -namespace Browar.Areas.HelpPage -{ - /// - /// This class will create an object of a given type and populate it with sample data. - /// - public class ObjectGenerator - { - internal const int DefaultCollectionSize = 2; - private readonly SimpleTypeObjectGenerator SimpleObjectGenerator = new SimpleTypeObjectGenerator(); - - /// - /// Generates an object for a given type. The type needs to be public, have a public default constructor and settable public properties/fields. Currently it supports the following types: - /// Simple types: , , , , , etc. - /// Complex types: POCO types. - /// Nullables: . - /// Arrays: arrays of simple types or complex types. - /// Key value pairs: - /// Tuples: , , etc - /// Dictionaries: or anything deriving from . - /// Collections: , , , , , or anything deriving from or . - /// Queryables: , . - /// - /// The type. - /// An object of the given type. - public object GenerateObject(Type type) - { - return GenerateObject(type, new Dictionary()); - } - - [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Here we just want to return null if anything goes wrong.")] - private object GenerateObject(Type type, Dictionary createdObjectReferences) - { - try - { - if (SimpleTypeObjectGenerator.CanGenerateObject(type)) - { - return SimpleObjectGenerator.GenerateObject(type); - } - - if (type.IsArray) - { - return GenerateArray(type, DefaultCollectionSize, createdObjectReferences); - } - - if (type.IsGenericType) - { - return GenerateGenericType(type, DefaultCollectionSize, createdObjectReferences); - } - - if (type == typeof(IDictionary)) - { - return GenerateDictionary(typeof(Hashtable), DefaultCollectionSize, createdObjectReferences); - } - - if (typeof(IDictionary).IsAssignableFrom(type)) - { - return GenerateDictionary(type, DefaultCollectionSize, createdObjectReferences); - } - - if (type == typeof(IList) || - type == typeof(IEnumerable) || - type == typeof(ICollection)) - { - return GenerateCollection(typeof(ArrayList), DefaultCollectionSize, createdObjectReferences); - } - - if (typeof(IList).IsAssignableFrom(type)) - { - return GenerateCollection(type, DefaultCollectionSize, createdObjectReferences); - } - - if (type == typeof(IQueryable)) - { - return GenerateQueryable(type, DefaultCollectionSize, createdObjectReferences); - } - - if (type.IsEnum) - { - return GenerateEnum(type); - } - - if (type.IsPublic || type.IsNestedPublic) - { - return GenerateComplexObject(type, createdObjectReferences); - } - } - catch - { - // Returns null if anything fails - return null; - } - - return null; - } - - private static object GenerateGenericType(Type type, int collectionSize, Dictionary createdObjectReferences) - { - Type genericTypeDefinition = type.GetGenericTypeDefinition(); - if (genericTypeDefinition == typeof(Nullable<>)) - { - return GenerateNullable(type, createdObjectReferences); - } - - if (genericTypeDefinition == typeof(KeyValuePair<,>)) - { - return GenerateKeyValuePair(type, createdObjectReferences); - } - - if (IsTuple(genericTypeDefinition)) - { - return GenerateTuple(type, createdObjectReferences); - } - - Type[] genericArguments = type.GetGenericArguments(); - if (genericArguments.Length == 1) - { - if (genericTypeDefinition == typeof(IList<>) || - genericTypeDefinition == typeof(IEnumerable<>) || - genericTypeDefinition == typeof(ICollection<>)) - { - Type collectionType = typeof(List<>).MakeGenericType(genericArguments); - return GenerateCollection(collectionType, collectionSize, createdObjectReferences); - } - - if (genericTypeDefinition == typeof(IQueryable<>)) - { - return GenerateQueryable(type, collectionSize, createdObjectReferences); - } - - Type closedCollectionType = typeof(ICollection<>).MakeGenericType(genericArguments[0]); - if (closedCollectionType.IsAssignableFrom(type)) - { - return GenerateCollection(type, collectionSize, createdObjectReferences); - } - } - - if (genericArguments.Length == 2) - { - if (genericTypeDefinition == typeof(IDictionary<,>)) - { - Type dictionaryType = typeof(Dictionary<,>).MakeGenericType(genericArguments); - return GenerateDictionary(dictionaryType, collectionSize, createdObjectReferences); - } - - Type closedDictionaryType = typeof(IDictionary<,>).MakeGenericType(genericArguments[0], genericArguments[1]); - if (closedDictionaryType.IsAssignableFrom(type)) - { - return GenerateDictionary(type, collectionSize, createdObjectReferences); - } - } - - if (type.IsPublic || type.IsNestedPublic) - { - return GenerateComplexObject(type, createdObjectReferences); - } - - return null; - } - - private static object GenerateTuple(Type type, Dictionary createdObjectReferences) - { - Type[] genericArgs = type.GetGenericArguments(); - object[] parameterValues = new object[genericArgs.Length]; - bool failedToCreateTuple = true; - ObjectGenerator objectGenerator = new ObjectGenerator(); - for (int i = 0; i < genericArgs.Length; i++) - { - parameterValues[i] = objectGenerator.GenerateObject(genericArgs[i], createdObjectReferences); - failedToCreateTuple &= parameterValues[i] == null; - } - if (failedToCreateTuple) - { - return null; - } - object result = Activator.CreateInstance(type, parameterValues); - return result; - } - - private static bool IsTuple(Type genericTypeDefinition) - { - return genericTypeDefinition == typeof(Tuple<>) || - genericTypeDefinition == typeof(Tuple<,>) || - genericTypeDefinition == typeof(Tuple<,,>) || - genericTypeDefinition == typeof(Tuple<,,,>) || - genericTypeDefinition == typeof(Tuple<,,,,>) || - genericTypeDefinition == typeof(Tuple<,,,,,>) || - genericTypeDefinition == typeof(Tuple<,,,,,,>) || - genericTypeDefinition == typeof(Tuple<,,,,,,,>); - } - - private static object GenerateKeyValuePair(Type keyValuePairType, Dictionary createdObjectReferences) - { - Type[] genericArgs = keyValuePairType.GetGenericArguments(); - Type typeK = genericArgs[0]; - Type typeV = genericArgs[1]; - ObjectGenerator objectGenerator = new ObjectGenerator(); - object keyObject = objectGenerator.GenerateObject(typeK, createdObjectReferences); - object valueObject = objectGenerator.GenerateObject(typeV, createdObjectReferences); - if (keyObject == null && valueObject == null) - { - // Failed to create key and values - return null; - } - object result = Activator.CreateInstance(keyValuePairType, keyObject, valueObject); - return result; - } - - private static object GenerateArray(Type arrayType, int size, Dictionary createdObjectReferences) - { - Type type = arrayType.GetElementType(); - Array result = Array.CreateInstance(type, size); - bool areAllElementsNull = true; - ObjectGenerator objectGenerator = new ObjectGenerator(); - for (int i = 0; i < size; i++) - { - object element = objectGenerator.GenerateObject(type, createdObjectReferences); - result.SetValue(element, i); - areAllElementsNull &= element == null; - } - - if (areAllElementsNull) - { - return null; - } - - return result; - } - - private static object GenerateDictionary(Type dictionaryType, int size, Dictionary createdObjectReferences) - { - Type typeK = typeof(object); - Type typeV = typeof(object); - if (dictionaryType.IsGenericType) - { - Type[] genericArgs = dictionaryType.GetGenericArguments(); - typeK = genericArgs[0]; - typeV = genericArgs[1]; - } - - object result = Activator.CreateInstance(dictionaryType); - MethodInfo addMethod = dictionaryType.GetMethod("Add") ?? dictionaryType.GetMethod("TryAdd"); - MethodInfo containsMethod = dictionaryType.GetMethod("Contains") ?? dictionaryType.GetMethod("ContainsKey"); - ObjectGenerator objectGenerator = new ObjectGenerator(); - for (int i = 0; i < size; i++) - { - object newKey = objectGenerator.GenerateObject(typeK, createdObjectReferences); - if (newKey == null) - { - // Cannot generate a valid key - return null; - } - - bool containsKey = (bool)containsMethod.Invoke(result, new object[] { newKey }); - if (!containsKey) - { - object newValue = objectGenerator.GenerateObject(typeV, createdObjectReferences); - addMethod.Invoke(result, new object[] { newKey, newValue }); - } - } - - return result; - } - - private static object GenerateEnum(Type enumType) - { - Array possibleValues = Enum.GetValues(enumType); - if (possibleValues.Length > 0) - { - return possibleValues.GetValue(0); - } - return null; - } - - private static object GenerateQueryable(Type queryableType, int size, Dictionary createdObjectReferences) - { - bool isGeneric = queryableType.IsGenericType; - object list; - if (isGeneric) - { - Type listType = typeof(List<>).MakeGenericType(queryableType.GetGenericArguments()); - list = GenerateCollection(listType, size, createdObjectReferences); - } - else - { - list = GenerateArray(typeof(object[]), size, createdObjectReferences); - } - if (list == null) - { - return null; - } - if (isGeneric) - { - Type argumentType = typeof(IEnumerable<>).MakeGenericType(queryableType.GetGenericArguments()); - MethodInfo asQueryableMethod = typeof(Queryable).GetMethod("AsQueryable", new[] { argumentType }); - return asQueryableMethod.Invoke(null, new[] { list }); - } - - return Queryable.AsQueryable((IEnumerable)list); - } - - private static object GenerateCollection(Type collectionType, int size, Dictionary createdObjectReferences) - { - Type type = collectionType.IsGenericType ? - collectionType.GetGenericArguments()[0] : - typeof(object); - object result = Activator.CreateInstance(collectionType); - MethodInfo addMethod = collectionType.GetMethod("Add"); - bool areAllElementsNull = true; - ObjectGenerator objectGenerator = new ObjectGenerator(); - for (int i = 0; i < size; i++) - { - object element = objectGenerator.GenerateObject(type, createdObjectReferences); - addMethod.Invoke(result, new object[] { element }); - areAllElementsNull &= element == null; - } - - if (areAllElementsNull) - { - return null; - } - - return result; - } - - private static object GenerateNullable(Type nullableType, Dictionary createdObjectReferences) - { - Type type = nullableType.GetGenericArguments()[0]; - ObjectGenerator objectGenerator = new ObjectGenerator(); - return objectGenerator.GenerateObject(type, createdObjectReferences); - } - - private static object GenerateComplexObject(Type type, Dictionary createdObjectReferences) - { - object result = null; - - if (createdObjectReferences.TryGetValue(type, out result)) - { - // The object has been created already, just return it. This will handle the circular reference case. - return result; - } - - if (type.IsValueType) - { - result = Activator.CreateInstance(type); - } - else - { - ConstructorInfo defaultCtor = type.GetConstructor(Type.EmptyTypes); - if (defaultCtor == null) - { - // Cannot instantiate the type because it doesn't have a default constructor - return null; - } - - result = defaultCtor.Invoke(new object[0]); - } - createdObjectReferences.Add(type, result); - SetPublicProperties(type, result, createdObjectReferences); - SetPublicFields(type, result, createdObjectReferences); - return result; - } - - private static void SetPublicProperties(Type type, object obj, Dictionary createdObjectReferences) - { - PropertyInfo[] properties = type.GetProperties(BindingFlags.Public | BindingFlags.Instance); - ObjectGenerator objectGenerator = new ObjectGenerator(); - foreach (PropertyInfo property in properties) - { - if (property.CanWrite) - { - object propertyValue = objectGenerator.GenerateObject(property.PropertyType, createdObjectReferences); - property.SetValue(obj, propertyValue, null); - } - } - } - - private static void SetPublicFields(Type type, object obj, Dictionary createdObjectReferences) - { - FieldInfo[] fields = type.GetFields(BindingFlags.Public | BindingFlags.Instance); - ObjectGenerator objectGenerator = new ObjectGenerator(); - foreach (FieldInfo field in fields) - { - object fieldValue = objectGenerator.GenerateObject(field.FieldType, createdObjectReferences); - field.SetValue(obj, fieldValue); - } - } - - private class SimpleTypeObjectGenerator - { - private long _index = 0; - private static readonly Dictionary> DefaultGenerators = InitializeGenerators(); - - [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity", Justification = "These are simple type factories and cannot be split up.")] - private static Dictionary> InitializeGenerators() - { - return new Dictionary> - { - { typeof(Boolean), index => true }, - { typeof(Byte), index => (Byte)64 }, - { typeof(Char), index => (Char)65 }, - { typeof(DateTime), index => DateTime.Now }, - { typeof(DateTimeOffset), index => new DateTimeOffset(DateTime.Now) }, - { typeof(DBNull), index => DBNull.Value }, - { typeof(Decimal), index => (Decimal)index }, - { typeof(Double), index => (Double)(index + 0.1) }, - { typeof(Guid), index => Guid.NewGuid() }, - { typeof(Int16), index => (Int16)(index % Int16.MaxValue) }, - { typeof(Int32), index => (Int32)(index % Int32.MaxValue) }, - { typeof(Int64), index => (Int64)index }, - { typeof(Object), index => new object() }, - { typeof(SByte), index => (SByte)64 }, - { typeof(Single), index => (Single)(index + 0.1) }, - { - typeof(String), index => - { - return String.Format(CultureInfo.CurrentCulture, "sample string {0}", index); - } - }, - { - typeof(TimeSpan), index => - { - return TimeSpan.FromTicks(1234567); - } - }, - { typeof(UInt16), index => (UInt16)(index % UInt16.MaxValue) }, - { typeof(UInt32), index => (UInt32)(index % UInt32.MaxValue) }, - { typeof(UInt64), index => (UInt64)index }, - { - typeof(Uri), index => - { - return new Uri(String.Format(CultureInfo.CurrentCulture, "http://webapihelppage{0}.com", index)); - } - }, - }; - } - - public static bool CanGenerateObject(Type type) - { - return DefaultGenerators.ContainsKey(type); - } - - public object GenerateObject(Type type) - { - return DefaultGenerators[type](++_index); - } - } - } -} \ No newline at end of file diff --git a/Browar/Browar/Areas/HelpPage/SampleGeneration/SampleDirection.cs b/Browar/Browar/Areas/HelpPage/SampleGeneration/SampleDirection.cs deleted file mode 100644 index c4d37dc..0000000 --- a/Browar/Browar/Areas/HelpPage/SampleGeneration/SampleDirection.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Browar.Areas.HelpPage -{ - /// - /// Indicates whether the sample is used for request or response - /// - public enum SampleDirection - { - Request = 0, - Response - } -} \ No newline at end of file diff --git a/Browar/Browar/Areas/HelpPage/SampleGeneration/TextSample.cs b/Browar/Browar/Areas/HelpPage/SampleGeneration/TextSample.cs deleted file mode 100644 index 7bb04e2..0000000 --- a/Browar/Browar/Areas/HelpPage/SampleGeneration/TextSample.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; - -namespace Browar.Areas.HelpPage -{ - /// - /// This represents a preformatted text sample on the help page. There's a display template named TextSample associated with this class. - /// - public class TextSample - { - public TextSample(string text) - { - if (text == null) - { - throw new ArgumentNullException("text"); - } - Text = text; - } - - public string Text { get; private set; } - - public override bool Equals(object obj) - { - TextSample other = obj as TextSample; - return other != null && Text == other.Text; - } - - public override int GetHashCode() - { - return Text.GetHashCode(); - } - - public override string ToString() - { - return Text; - } - } -} \ No newline at end of file diff --git a/Browar/Browar/Areas/HelpPage/Views/Help/Api.cshtml b/Browar/Browar/Areas/HelpPage/Views/Help/Api.cshtml deleted file mode 100644 index c02d9ca..0000000 --- a/Browar/Browar/Areas/HelpPage/Views/Help/Api.cshtml +++ /dev/null @@ -1,22 +0,0 @@ -@using System.Web.Http -@using Browar.Areas.HelpPage.Models -@model HelpPageApiModel - -@{ - var description = Model.ApiDescription; - ViewBag.Title = description.HttpMethod.Method + " " + description.RelativePath; -} - - -
- -
- @Html.DisplayForModel() -
-
diff --git a/Browar/Browar/Areas/HelpPage/Views/Help/DisplayTemplates/ApiGroup.cshtml b/Browar/Browar/Areas/HelpPage/Views/Help/DisplayTemplates/ApiGroup.cshtml deleted file mode 100644 index 3de0b37..0000000 --- a/Browar/Browar/Areas/HelpPage/Views/Help/DisplayTemplates/ApiGroup.cshtml +++ /dev/null @@ -1,41 +0,0 @@ -@using System.Web.Http -@using System.Web.Http.Controllers -@using System.Web.Http.Description -@using Browar.Areas.HelpPage -@using Browar.Areas.HelpPage.Models -@model IGrouping - -@{ - var controllerDocumentation = ViewBag.DocumentationProvider != null ? - ViewBag.DocumentationProvider.GetDocumentation(Model.Key) : - null; -} - -

@Model.Key.ControllerName

-@if (!String.IsNullOrEmpty(controllerDocumentation)) -{ -

@controllerDocumentation

-} - - - - - - @foreach (var api in Model) - { - - - - - } - -
APIDescription
@api.HttpMethod.Method @api.RelativePath - @if (api.Documentation != null) - { -

@api.Documentation

- } - else - { -

No documentation available.

- } -
\ No newline at end of file diff --git a/Browar/Browar/Areas/HelpPage/Views/Help/DisplayTemplates/CollectionModelDescription.cshtml b/Browar/Browar/Areas/HelpPage/Views/Help/DisplayTemplates/CollectionModelDescription.cshtml deleted file mode 100644 index 6d9ef7b..0000000 --- a/Browar/Browar/Areas/HelpPage/Views/Help/DisplayTemplates/CollectionModelDescription.cshtml +++ /dev/null @@ -1,6 +0,0 @@ -@using Browar.Areas.HelpPage.ModelDescriptions -@model CollectionModelDescription -@if (Model.ElementDescription is ComplexTypeModelDescription) -{ - @Html.DisplayFor(m => m.ElementDescription) -} \ No newline at end of file diff --git a/Browar/Browar/Areas/HelpPage/Views/Help/DisplayTemplates/ComplexTypeModelDescription.cshtml b/Browar/Browar/Areas/HelpPage/Views/Help/DisplayTemplates/ComplexTypeModelDescription.cshtml deleted file mode 100644 index 8285d5e..0000000 --- a/Browar/Browar/Areas/HelpPage/Views/Help/DisplayTemplates/ComplexTypeModelDescription.cshtml +++ /dev/null @@ -1,3 +0,0 @@ -@using Browar.Areas.HelpPage.ModelDescriptions -@model ComplexTypeModelDescription -@Html.DisplayFor(m => m.Properties, "Parameters") \ No newline at end of file diff --git a/Browar/Browar/Areas/HelpPage/Views/Help/DisplayTemplates/DictionaryModelDescription.cshtml b/Browar/Browar/Areas/HelpPage/Views/Help/DisplayTemplates/DictionaryModelDescription.cshtml deleted file mode 100644 index 97f362c..0000000 --- a/Browar/Browar/Areas/HelpPage/Views/Help/DisplayTemplates/DictionaryModelDescription.cshtml +++ /dev/null @@ -1,4 +0,0 @@ -@using Browar.Areas.HelpPage.ModelDescriptions -@model DictionaryModelDescription -Dictionary of @Html.DisplayFor(m => Model.KeyModelDescription.ModelType, "ModelDescriptionLink", new { modelDescription = Model.KeyModelDescription }) [key] -and @Html.DisplayFor(m => Model.ValueModelDescription.ModelType, "ModelDescriptionLink", new { modelDescription = Model.ValueModelDescription }) [value] \ No newline at end of file diff --git a/Browar/Browar/Areas/HelpPage/Views/Help/DisplayTemplates/EnumTypeModelDescription.cshtml b/Browar/Browar/Areas/HelpPage/Views/Help/DisplayTemplates/EnumTypeModelDescription.cshtml deleted file mode 100644 index a3d41e7..0000000 --- a/Browar/Browar/Areas/HelpPage/Views/Help/DisplayTemplates/EnumTypeModelDescription.cshtml +++ /dev/null @@ -1,24 +0,0 @@ -@using Browar.Areas.HelpPage.ModelDescriptions -@model EnumTypeModelDescription - -

Possible enumeration values:

- - - - - - - @foreach (EnumValueDescription value in Model.Values) - { - - - - - - } - -
NameValueDescription
@value.Name -

@value.Value

-
-

@value.Documentation

-
\ No newline at end of file diff --git a/Browar/Browar/Areas/HelpPage/Views/Help/DisplayTemplates/HelpPageApiModel.cshtml b/Browar/Browar/Areas/HelpPage/Views/Help/DisplayTemplates/HelpPageApiModel.cshtml deleted file mode 100644 index 2940577..0000000 --- a/Browar/Browar/Areas/HelpPage/Views/Help/DisplayTemplates/HelpPageApiModel.cshtml +++ /dev/null @@ -1,67 +0,0 @@ -@using System.Web.Http -@using System.Web.Http.Description -@using Browar.Areas.HelpPage.Models -@using Browar.Areas.HelpPage.ModelDescriptions -@model HelpPageApiModel - -@{ - ApiDescription description = Model.ApiDescription; -} -

@description.HttpMethod.Method @description.RelativePath

-
-

@description.Documentation

- -

Request Information

- -

URI Parameters

- @Html.DisplayFor(m => m.UriParameters, "Parameters") - -

Body Parameters

- -

@Model.RequestDocumentation

- - @if (Model.RequestModelDescription != null) - { - @Html.DisplayFor(m => m.RequestModelDescription.ModelType, "ModelDescriptionLink", new { modelDescription = Model.RequestModelDescription }) - if (Model.RequestBodyParameters != null) - { - @Html.DisplayFor(m => m.RequestBodyParameters, "Parameters") - } - } - else - { -

None.

- } - - @if (Model.SampleRequests.Count > 0) - { -

Request Formats

- @Html.DisplayFor(m => m.SampleRequests, "Samples") - } - -

Response Information

- -

Resource Description

- -

@description.ResponseDescription.Documentation

- - @if (Model.ResourceDescription != null) - { - @Html.DisplayFor(m => m.ResourceDescription.ModelType, "ModelDescriptionLink", new { modelDescription = Model.ResourceDescription }) - if (Model.ResourceProperties != null) - { - @Html.DisplayFor(m => m.ResourceProperties, "Parameters") - } - } - else - { -

None.

- } - - @if (Model.SampleResponses.Count > 0) - { -

Response Formats

- @Html.DisplayFor(m => m.SampleResponses, "Samples") - } - -
\ No newline at end of file diff --git a/Browar/Browar/Areas/HelpPage/Views/Help/DisplayTemplates/ImageSample.cshtml b/Browar/Browar/Areas/HelpPage/Views/Help/DisplayTemplates/ImageSample.cshtml deleted file mode 100644 index 8623d8d..0000000 --- a/Browar/Browar/Areas/HelpPage/Views/Help/DisplayTemplates/ImageSample.cshtml +++ /dev/null @@ -1,4 +0,0 @@ -@using Browar.Areas.HelpPage -@model ImageSample - - \ No newline at end of file diff --git a/Browar/Browar/Areas/HelpPage/Views/Help/DisplayTemplates/InvalidSample.cshtml b/Browar/Browar/Areas/HelpPage/Views/Help/DisplayTemplates/InvalidSample.cshtml deleted file mode 100644 index 13f43e6..0000000 --- a/Browar/Browar/Areas/HelpPage/Views/Help/DisplayTemplates/InvalidSample.cshtml +++ /dev/null @@ -1,13 +0,0 @@ -@using Browar.Areas.HelpPage -@model InvalidSample - -@if (HttpContext.Current.IsDebuggingEnabled) -{ -
-

@Model.ErrorMessage

-
-} -else -{ -

Sample not available.

-} \ No newline at end of file diff --git a/Browar/Browar/Areas/HelpPage/Views/Help/DisplayTemplates/KeyValuePairModelDescription.cshtml b/Browar/Browar/Areas/HelpPage/Views/Help/DisplayTemplates/KeyValuePairModelDescription.cshtml deleted file mode 100644 index 5b7a30c..0000000 --- a/Browar/Browar/Areas/HelpPage/Views/Help/DisplayTemplates/KeyValuePairModelDescription.cshtml +++ /dev/null @@ -1,4 +0,0 @@ -@using Browar.Areas.HelpPage.ModelDescriptions -@model KeyValuePairModelDescription -Pair of @Html.DisplayFor(m => Model.KeyModelDescription.ModelType, "ModelDescriptionLink", new { modelDescription = Model.KeyModelDescription }) [key] -and @Html.DisplayFor(m => Model.ValueModelDescription.ModelType, "ModelDescriptionLink", new { modelDescription = Model.ValueModelDescription }) [value] \ No newline at end of file diff --git a/Browar/Browar/Areas/HelpPage/Views/Help/DisplayTemplates/ModelDescriptionLink.cshtml b/Browar/Browar/Areas/HelpPage/Views/Help/DisplayTemplates/ModelDescriptionLink.cshtml deleted file mode 100644 index 72a85d5..0000000 --- a/Browar/Browar/Areas/HelpPage/Views/Help/DisplayTemplates/ModelDescriptionLink.cshtml +++ /dev/null @@ -1,26 +0,0 @@ -@using Browar.Areas.HelpPage.ModelDescriptions -@model Type -@{ - ModelDescription modelDescription = ViewBag.modelDescription; - if (modelDescription is ComplexTypeModelDescription || modelDescription is EnumTypeModelDescription) - { - if (Model == typeof(Object)) - { - @:Object - } - else - { - @Html.ActionLink(modelDescription.Name, "ResourceModel", "Help", new { modelName = modelDescription.Name }, null) - } - } - else if (modelDescription is CollectionModelDescription) - { - var collectionDescription = modelDescription as CollectionModelDescription; - var elementDescription = collectionDescription.ElementDescription; - @:Collection of @Html.DisplayFor(m => elementDescription.ModelType, "ModelDescriptionLink", new { modelDescription = elementDescription }) - } - else - { - @Html.DisplayFor(m => modelDescription) - } -} \ No newline at end of file diff --git a/Browar/Browar/Areas/HelpPage/Views/Help/DisplayTemplates/Parameters.cshtml b/Browar/Browar/Areas/HelpPage/Views/Help/DisplayTemplates/Parameters.cshtml deleted file mode 100644 index d8688d8..0000000 --- a/Browar/Browar/Areas/HelpPage/Views/Help/DisplayTemplates/Parameters.cshtml +++ /dev/null @@ -1,48 +0,0 @@ -@using System.Collections.Generic -@using System.Collections.ObjectModel -@using System.Web.Http.Description -@using System.Threading -@using Browar.Areas.HelpPage.ModelDescriptions -@model IList - -@if (Model.Count > 0) -{ - - - - - - @foreach (ParameterDescription parameter in Model) - { - ModelDescription modelDescription = parameter.TypeDescription; - - - - - - - } - -
NameDescriptionTypeAdditional information
@parameter.Name -

@parameter.Documentation

-
- @Html.DisplayFor(m => modelDescription.ModelType, "ModelDescriptionLink", new { modelDescription = modelDescription }) - - @if (parameter.Annotations.Count > 0) - { - foreach (var annotation in parameter.Annotations) - { -

@annotation.Documentation

- } - } - else - { -

None.

- } -
-} -else -{ -

None.

-} - diff --git a/Browar/Browar/Areas/HelpPage/Views/Help/DisplayTemplates/Samples.cshtml b/Browar/Browar/Areas/HelpPage/Views/Help/DisplayTemplates/Samples.cshtml deleted file mode 100644 index c19596f..0000000 --- a/Browar/Browar/Areas/HelpPage/Views/Help/DisplayTemplates/Samples.cshtml +++ /dev/null @@ -1,30 +0,0 @@ -@using System.Net.Http.Headers -@model Dictionary - -@{ - // Group the samples into a single tab if they are the same. - Dictionary samples = Model.GroupBy(pair => pair.Value).ToDictionary( - pair => String.Join(", ", pair.Select(m => m.Key.ToString()).ToArray()), - pair => pair.Key); - var mediaTypes = samples.Keys; -} -
- @foreach (var mediaType in mediaTypes) - { -

@mediaType

-
- Sample: - @{ - var sample = samples[mediaType]; - if (sample == null) - { -

Sample not available.

- } - else - { - @Html.DisplayFor(s => sample); - } - } -
- } -
\ No newline at end of file diff --git a/Browar/Browar/Areas/HelpPage/Views/Help/DisplayTemplates/SimpleTypeModelDescription.cshtml b/Browar/Browar/Areas/HelpPage/Views/Help/DisplayTemplates/SimpleTypeModelDescription.cshtml deleted file mode 100644 index 10fd712..0000000 --- a/Browar/Browar/Areas/HelpPage/Views/Help/DisplayTemplates/SimpleTypeModelDescription.cshtml +++ /dev/null @@ -1,3 +0,0 @@ -@using Browar.Areas.HelpPage.ModelDescriptions -@model SimpleTypeModelDescription -@Model.Documentation \ No newline at end of file diff --git a/Browar/Browar/Areas/HelpPage/Views/Help/DisplayTemplates/TextSample.cshtml b/Browar/Browar/Areas/HelpPage/Views/Help/DisplayTemplates/TextSample.cshtml deleted file mode 100644 index 681c6d9..0000000 --- a/Browar/Browar/Areas/HelpPage/Views/Help/DisplayTemplates/TextSample.cshtml +++ /dev/null @@ -1,6 +0,0 @@ -@using Browar.Areas.HelpPage -@model TextSample - -
-@Model.Text
-
\ No newline at end of file diff --git a/Browar/Browar/Areas/HelpPage/Views/Help/Index.cshtml b/Browar/Browar/Areas/HelpPage/Views/Help/Index.cshtml deleted file mode 100644 index cd0082a..0000000 --- a/Browar/Browar/Areas/HelpPage/Views/Help/Index.cshtml +++ /dev/null @@ -1,38 +0,0 @@ -@using System.Web.Http -@using System.Web.Http.Controllers -@using System.Web.Http.Description -@using System.Collections.ObjectModel -@using Browar.Areas.HelpPage.Models -@model Collection - -@{ - ViewBag.Title = "ASP.NET Web API Help Page"; - - // Group APIs by controller - ILookup apiGroups = Model.ToLookup(api => api.ActionDescriptor.ControllerDescriptor); -} - - -
-
-
-

@ViewBag.Title

-
-
-
-
- -
- @foreach (var group in apiGroups) - { - @Html.DisplayFor(m => group, "ApiGroup") - } -
-
diff --git a/Browar/Browar/Areas/HelpPage/Views/Help/ResourceModel.cshtml b/Browar/Browar/Areas/HelpPage/Views/Help/ResourceModel.cshtml deleted file mode 100644 index 89ce7f7..0000000 --- a/Browar/Browar/Areas/HelpPage/Views/Help/ResourceModel.cshtml +++ /dev/null @@ -1,19 +0,0 @@ -@using System.Web.Http -@using Browar.Areas.HelpPage.ModelDescriptions -@model ModelDescription - - -
- -

@Model.Name

-

@Model.Documentation

-
- @Html.DisplayFor(m => Model) -
-
diff --git a/Browar/Browar/Areas/HelpPage/Views/Shared/_Layout.cshtml b/Browar/Browar/Areas/HelpPage/Views/Shared/_Layout.cshtml deleted file mode 100644 index bc2e96f..0000000 --- a/Browar/Browar/Areas/HelpPage/Views/Shared/_Layout.cshtml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - @ViewBag.Title - @RenderSection("scripts", required: false) - - - @RenderBody() - - \ No newline at end of file diff --git a/Browar/Browar/Areas/HelpPage/Views/Web.config b/Browar/Browar/Areas/HelpPage/Views/Web.config deleted file mode 100644 index e3602a4..0000000 --- a/Browar/Browar/Areas/HelpPage/Views/Web.config +++ /dev/null @@ -1,41 +0,0 @@ - - - - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Browar/Browar/Areas/HelpPage/Views/_ViewStart.cshtml b/Browar/Browar/Areas/HelpPage/Views/_ViewStart.cshtml deleted file mode 100644 index d735b1c..0000000 --- a/Browar/Browar/Areas/HelpPage/Views/_ViewStart.cshtml +++ /dev/null @@ -1,4 +0,0 @@ -@{ - // Change the Layout path below to blend the look and feel of the help page with your existing web pages - Layout = "~/Views/Shared/_Layout.cshtml"; -} \ No newline at end of file diff --git a/Browar/Browar/Areas/HelpPage/XmlDocumentationProvider.cs b/Browar/Browar/Areas/HelpPage/XmlDocumentationProvider.cs deleted file mode 100644 index 4f9030e..0000000 --- a/Browar/Browar/Areas/HelpPage/XmlDocumentationProvider.cs +++ /dev/null @@ -1,161 +0,0 @@ -using System; -using System.Globalization; -using System.Linq; -using System.Reflection; -using System.Web.Http.Controllers; -using System.Web.Http.Description; -using System.Xml.XPath; -using Browar.Areas.HelpPage.ModelDescriptions; - -namespace Browar.Areas.HelpPage -{ - /// - /// A custom that reads the API documentation from an XML documentation file. - /// - public class XmlDocumentationProvider : IDocumentationProvider, IModelDocumentationProvider - { - private XPathNavigator _documentNavigator; - private const string TypeExpression = "/doc/members/member[@name='T:{0}']"; - private const string MethodExpression = "/doc/members/member[@name='M:{0}']"; - private const string PropertyExpression = "/doc/members/member[@name='P:{0}']"; - private const string FieldExpression = "/doc/members/member[@name='F:{0}']"; - private const string ParameterExpression = "param[@name='{0}']"; - - /// - /// Initializes a new instance of the class. - /// - /// The physical path to XML document. - public XmlDocumentationProvider(string documentPath) - { - if (documentPath == null) - { - throw new ArgumentNullException("documentPath"); - } - XPathDocument xpath = new XPathDocument(documentPath); - _documentNavigator = xpath.CreateNavigator(); - } - - public string GetDocumentation(HttpControllerDescriptor controllerDescriptor) - { - XPathNavigator typeNode = GetTypeNode(controllerDescriptor.ControllerType); - return GetTagValue(typeNode, "summary"); - } - - public virtual string GetDocumentation(HttpActionDescriptor actionDescriptor) - { - XPathNavigator methodNode = GetMethodNode(actionDescriptor); - return GetTagValue(methodNode, "summary"); - } - - public virtual string GetDocumentation(HttpParameterDescriptor parameterDescriptor) - { - ReflectedHttpParameterDescriptor reflectedParameterDescriptor = parameterDescriptor as ReflectedHttpParameterDescriptor; - if (reflectedParameterDescriptor != null) - { - XPathNavigator methodNode = GetMethodNode(reflectedParameterDescriptor.ActionDescriptor); - if (methodNode != null) - { - string parameterName = reflectedParameterDescriptor.ParameterInfo.Name; - XPathNavigator parameterNode = methodNode.SelectSingleNode(String.Format(CultureInfo.InvariantCulture, ParameterExpression, parameterName)); - if (parameterNode != null) - { - return parameterNode.Value.Trim(); - } - } - } - - return null; - } - - public string GetResponseDocumentation(HttpActionDescriptor actionDescriptor) - { - XPathNavigator methodNode = GetMethodNode(actionDescriptor); - return GetTagValue(methodNode, "returns"); - } - - public string GetDocumentation(MemberInfo member) - { - string memberName = String.Format(CultureInfo.InvariantCulture, "{0}.{1}", GetTypeName(member.DeclaringType), member.Name); - string expression = member.MemberType == MemberTypes.Field ? FieldExpression : PropertyExpression; - string selectExpression = String.Format(CultureInfo.InvariantCulture, expression, memberName); - XPathNavigator propertyNode = _documentNavigator.SelectSingleNode(selectExpression); - return GetTagValue(propertyNode, "summary"); - } - - public string GetDocumentation(Type type) - { - XPathNavigator typeNode = GetTypeNode(type); - return GetTagValue(typeNode, "summary"); - } - - private XPathNavigator GetMethodNode(HttpActionDescriptor actionDescriptor) - { - ReflectedHttpActionDescriptor reflectedActionDescriptor = actionDescriptor as ReflectedHttpActionDescriptor; - if (reflectedActionDescriptor != null) - { - string selectExpression = String.Format(CultureInfo.InvariantCulture, MethodExpression, GetMemberName(reflectedActionDescriptor.MethodInfo)); - return _documentNavigator.SelectSingleNode(selectExpression); - } - - return null; - } - - private static string GetMemberName(MethodInfo method) - { - string name = String.Format(CultureInfo.InvariantCulture, "{0}.{1}", GetTypeName(method.DeclaringType), method.Name); - ParameterInfo[] parameters = method.GetParameters(); - if (parameters.Length != 0) - { - string[] parameterTypeNames = parameters.Select(param => GetTypeName(param.ParameterType)).ToArray(); - name += String.Format(CultureInfo.InvariantCulture, "({0})", String.Join(",", parameterTypeNames)); - } - - return name; - } - - private static string GetTagValue(XPathNavigator parentNode, string tagName) - { - if (parentNode != null) - { - XPathNavigator node = parentNode.SelectSingleNode(tagName); - if (node != null) - { - return node.Value.Trim(); - } - } - - return null; - } - - private XPathNavigator GetTypeNode(Type type) - { - string controllerTypeName = GetTypeName(type); - string selectExpression = String.Format(CultureInfo.InvariantCulture, TypeExpression, controllerTypeName); - return _documentNavigator.SelectSingleNode(selectExpression); - } - - private static string GetTypeName(Type type) - { - string name = type.FullName; - if (type.IsGenericType) - { - // Format the generic type name to something like: Generic{System.Int32,System.String} - Type genericType = type.GetGenericTypeDefinition(); - Type[] genericArguments = type.GetGenericArguments(); - string genericTypeName = genericType.FullName; - - // Trim the generic parameter counts from the name - genericTypeName = genericTypeName.Substring(0, genericTypeName.IndexOf('`')); - string[] argumentTypeNames = genericArguments.Select(t => GetTypeName(t)).ToArray(); - name = String.Format(CultureInfo.InvariantCulture, "{0}{{{1}}}", genericTypeName, String.Join(",", argumentTypeNames)); - } - if (type.IsNested) - { - // Changing the nested type name from OuterType+InnerType to OuterType.InnerType to match the XML documentation syntax. - name = name.Replace("+", "."); - } - - return name; - } - } -} diff --git a/Browar/Browar/Browar.csproj b/Browar/Browar/Browar.csproj index e0e4373..028483f 100644 --- a/Browar/Browar/Browar.csproj +++ b/Browar/Browar/Browar.csproj @@ -49,6 +49,7 @@ + @@ -119,43 +120,20 @@ + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + Global.asax @@ -163,16 +141,33 @@ 201410171546010_Initial.cs + + + 201410181353294_Initial1.cs + + + + 201410181403110_Initial2.cs + + + + + + + + True + True + Reference.svcmap + - @@ -181,25 +176,6 @@ - - - - - - - - - - - - - - - - - - - @@ -208,14 +184,24 @@ - + + Reference.svcmap + + + + + WCF Proxy Generator + Reference.cs + + + Designer + Web.config Web.config - @@ -224,11 +210,19 @@ + + 201410171546010_Initial.cs + + 201410181353294_Initial1.cs + + + 201410181403110_Initial2.cs + @@ -237,6 +231,12 @@ + + + + + + 10.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) diff --git a/Browar/Browar/Browar.csproj.user b/Browar/Browar/Browar.csproj.user index 5113ae9..91f3865 100644 --- a/Browar/Browar/Browar.csproj.user +++ b/Browar/Browar/Browar.csproj.user @@ -9,6 +9,7 @@ Browar.Models.BrowarContext True + 600 diff --git a/Browar/Browar/Controllers/AddController.cs b/Browar/Browar/Controllers/AddController.cs new file mode 100644 index 0000000..5f60f72 --- /dev/null +++ b/Browar/Browar/Controllers/AddController.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.Mvc; + +namespace Browar.Controllers +{ + public class AddController : Controller + { + public ActionResult Index() + { + ViewBag.Title = "Dodawanie"; + + return View(); + } + } +} \ No newline at end of file diff --git a/Browar/Browar/Controllers/BrowarniasController.cs b/Browar/Browar/Controllers/BrowarniasController.cs index 4217558..7ed8d75 100644 --- a/Browar/Browar/Controllers/BrowarniasController.cs +++ b/Browar/Browar/Controllers/BrowarniasController.cs @@ -18,23 +18,35 @@ public class BrowarniasController : ApiController private BrowarContext db = new BrowarContext(); // GET: api/Browarnias - public IQueryable GetBrowarnias() + public IQueryable GetBrowarnias() { - return db.Browarnias; + var browarnias = from b in db.Browarnias + select new BrowarniaDTO() + { + Id = b.Id, + Name = b.Name, + }; + + return browarnias; } // GET: api/Browarnias/5 - [ResponseType(typeof(Browarnia))] + [ResponseType(typeof(BrowarniaDetailDTO))] public async Task GetBrowarnia(int id) { - Browarnia browarnia = await db.Browarnias.FindAsync(id); + var browarnia = await db.Browarnias.Select(p => + new BrowarniaDetailDTO() + { + Id = p.Id, + Name = p.Name, + }).SingleOrDefaultAsync(p => p.Id == id); if (browarnia == null) { return NotFound(); } return Ok(browarnia); - } + } // PUT: api/Browarnias/5 [ResponseType(typeof(void))] diff --git a/Browar/Browar/Controllers/CommentsController.cs b/Browar/Browar/Controllers/CommentsController.cs new file mode 100644 index 0000000..2edeb59 --- /dev/null +++ b/Browar/Browar/Controllers/CommentsController.cs @@ -0,0 +1,119 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Data.Entity; +using System.Data.Entity.Infrastructure; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Threading.Tasks; +using System.Web.Http; +using System.Web.Http.Description; +using Browar.Models; + +namespace Browar.Controllers +{ + public class CommentsController : ApiController + { + private BrowarContext db = new BrowarContext(); + + // GET: api/Comments + public IQueryable GetComments() + { + return db.Comments; + } + + // GET: api/Comments/5 + [ResponseType(typeof(Comment))] + public async Task GetComment(int id) + { + Comment comment = await db.Comments.FindAsync(id); + if (comment == null) + { + return NotFound(); + } + + return Ok(comment); + } + + // PUT: api/Comments/5 + [ResponseType(typeof(void))] + public async Task PutComment(int id, Comment comment) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + if (id != comment.Id) + { + return BadRequest(); + } + + db.Entry(comment).State = EntityState.Modified; + + try + { + await db.SaveChangesAsync(); + } + catch (DbUpdateConcurrencyException) + { + if (!CommentExists(id)) + { + return NotFound(); + } + else + { + throw; + } + } + + return StatusCode(HttpStatusCode.NoContent); + } + + // POST: api/Comments + [ResponseType(typeof(Comment))] + public async Task PostComment(Comment comment) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + db.Comments.Add(comment); + await db.SaveChangesAsync(); + + return CreatedAtRoute("DefaultApi", new { id = comment.Id }, comment); + } + + // DELETE: api/Comments/5 + [ResponseType(typeof(Comment))] + public async Task DeleteComment(int id) + { + Comment comment = await db.Comments.FindAsync(id); + if (comment == null) + { + return NotFound(); + } + + db.Comments.Remove(comment); + await db.SaveChangesAsync(); + + return Ok(comment); + } + + protected override void Dispose(bool disposing) + { + if (disposing) + { + db.Dispose(); + } + base.Dispose(disposing); + } + + private bool CommentExists(int id) + { + return db.Comments.Count(e => e.Id == id) > 0; + } + } +} \ No newline at end of file diff --git a/Browar/Browar/Controllers/PiwoesController.cs b/Browar/Browar/Controllers/PiwoesController.cs index 9839256..09700ee 100644 --- a/Browar/Browar/Controllers/PiwoesController.cs +++ b/Browar/Browar/Controllers/PiwoesController.cs @@ -13,8 +13,11 @@ namespace Browar.Controllers { + using Browar.Serwer; + public class PiwoesController : ApiController { + private Serwer.ServiceSoapClient klient = new ServiceSoapClient(); private BrowarContext db = new BrowarContext(); // GET: api/Piwoes @@ -27,7 +30,6 @@ public IQueryable GetPiwoes() Name = p.Name, Browarnia = p.Browarnia.Name }; - return piwoes; } @@ -49,7 +51,8 @@ public async Task GetPiwo(int id) { return NotFound(); } - + var hello = klient.HelloWorld(); + piwo.Name = hello; return Ok(piwo); } diff --git a/Browar/Browar/Controllers/RatesController.cs b/Browar/Browar/Controllers/RatesController.cs new file mode 100644 index 0000000..730be6f --- /dev/null +++ b/Browar/Browar/Controllers/RatesController.cs @@ -0,0 +1,119 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Data.Entity; +using System.Data.Entity.Infrastructure; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Threading.Tasks; +using System.Web.Http; +using System.Web.Http.Description; +using Browar.Models; + +namespace Browar.Controllers +{ + public class RatesController : ApiController + { + private BrowarContext db = new BrowarContext(); + + // GET: api/Rates + public IQueryable GetRates() + { + return db.Rates; + } + + // GET: api/Rates/5 + [ResponseType(typeof(Rate))] + public async Task GetRate(int id) + { + Rate rate = await db.Rates.FindAsync(id); + if (rate == null) + { + return NotFound(); + } + + return Ok(rate); + } + + // PUT: api/Rates/5 + [ResponseType(typeof(void))] + public async Task PutRate(int id, Rate rate) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + if (id != rate.Id) + { + return BadRequest(); + } + + db.Entry(rate).State = EntityState.Modified; + + try + { + await db.SaveChangesAsync(); + } + catch (DbUpdateConcurrencyException) + { + if (!RateExists(id)) + { + return NotFound(); + } + else + { + throw; + } + } + + return StatusCode(HttpStatusCode.NoContent); + } + + // POST: api/Rates + [ResponseType(typeof(Rate))] + public async Task PostRate(Rate rate) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + db.Rates.Add(rate); + await db.SaveChangesAsync(); + + return CreatedAtRoute("DefaultApi", new { id = rate.Id }, rate); + } + + // DELETE: api/Rates/5 + [ResponseType(typeof(Rate))] + public async Task DeleteRate(int id) + { + Rate rate = await db.Rates.FindAsync(id); + if (rate == null) + { + return NotFound(); + } + + db.Rates.Remove(rate); + await db.SaveChangesAsync(); + + return Ok(rate); + } + + protected override void Dispose(bool disposing) + { + if (disposing) + { + db.Dispose(); + } + base.Dispose(disposing); + } + + private bool RateExists(int id) + { + return db.Rates.Count(e => e.Id == id) > 0; + } + } +} \ No newline at end of file diff --git a/Browar/Browar/Controllers/UsersController.cs b/Browar/Browar/Controllers/UsersController.cs new file mode 100644 index 0000000..edf44cf --- /dev/null +++ b/Browar/Browar/Controllers/UsersController.cs @@ -0,0 +1,119 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Data.Entity; +using System.Data.Entity.Infrastructure; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Threading.Tasks; +using System.Web.Http; +using System.Web.Http.Description; +using Browar.Models; + +namespace Browar.Controllers +{ + public class UsersController : ApiController + { + private BrowarContext db = new BrowarContext(); + + // GET: api/Users + public IQueryable GetUsers() + { + return db.Users; + } + + // GET: api/Users/5 + [ResponseType(typeof(User))] + public async Task GetUser(int id) + { + User user = await db.Users.FindAsync(id); + if (user == null) + { + return NotFound(); + } + + return Ok(user); + } + + // PUT: api/Users/5 + [ResponseType(typeof(void))] + public async Task PutUser(int id, User user) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + if (id != user.Id) + { + return BadRequest(); + } + + db.Entry(user).State = EntityState.Modified; + + try + { + await db.SaveChangesAsync(); + } + catch (DbUpdateConcurrencyException) + { + if (!UserExists(id)) + { + return NotFound(); + } + else + { + throw; + } + } + + return StatusCode(HttpStatusCode.NoContent); + } + + // POST: api/Users + [ResponseType(typeof(User))] + public async Task PostUser(User user) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + db.Users.Add(user); + await db.SaveChangesAsync(); + + return CreatedAtRoute("DefaultApi", new { id = user.Id }, user); + } + + // DELETE: api/Users/5 + [ResponseType(typeof(User))] + public async Task DeleteUser(int id) + { + User user = await db.Users.FindAsync(id); + if (user == null) + { + return NotFound(); + } + + db.Users.Remove(user); + await db.SaveChangesAsync(); + + return Ok(user); + } + + protected override void Dispose(bool disposing) + { + if (disposing) + { + db.Dispose(); + } + base.Dispose(disposing); + } + + private bool UserExists(int id) + { + return db.Users.Count(e => e.Id == id) > 0; + } + } +} \ No newline at end of file diff --git a/Browar/Browar/Migrations/201410181353294_Initial1.Designer.cs b/Browar/Browar/Migrations/201410181353294_Initial1.Designer.cs new file mode 100644 index 0000000..13914e4 --- /dev/null +++ b/Browar/Browar/Migrations/201410181353294_Initial1.Designer.cs @@ -0,0 +1,29 @@ +// +namespace Browar.Migrations +{ + using System.CodeDom.Compiler; + using System.Data.Entity.Migrations; + using System.Data.Entity.Migrations.Infrastructure; + using System.Resources; + + [GeneratedCode("EntityFramework.Migrations", "6.0.0-20911")] + public sealed partial class Initial1 : IMigrationMetadata + { + private readonly ResourceManager Resources = new ResourceManager(typeof(Initial1)); + + string IMigrationMetadata.Id + { + get { return "201410181353294_Initial1"; } + } + + string IMigrationMetadata.Source + { + get { return null; } + } + + string IMigrationMetadata.Target + { + get { return Resources.GetString("Target"); } + } + } +} diff --git a/Browar/Browar/Migrations/201410181353294_Initial1.cs b/Browar/Browar/Migrations/201410181353294_Initial1.cs new file mode 100644 index 0000000..5c5a924 --- /dev/null +++ b/Browar/Browar/Migrations/201410181353294_Initial1.cs @@ -0,0 +1,18 @@ +namespace Browar.Migrations +{ + using System; + using System.Data.Entity.Migrations; + + public partial class Initial1 : DbMigration + { + public override void Up() + { + AddColumn("dbo.Piwoes", "Img", c => c.String()); + } + + public override void Down() + { + DropColumn("dbo.Piwoes", "Img"); + } + } +} diff --git a/Browar/Browar/Migrations/201410181353294_Initial1.resx b/Browar/Browar/Migrations/201410181353294_Initial1.resx new file mode 100644 index 0000000..ed6087f --- /dev/null +++ b/Browar/Browar/Migrations/201410181353294_Initial1.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + H4sIAAAAAAAEAO1ZzW7jNhC+F+g7CDq1BdZKspc2sHeRdZIiaJ0EUXavASONHaIUqZJUYj/bHvpIfYUO9UuJkq04m3YX6MWwRzPf/HI4I//9+a/p+3XCvEeQigo+8w8nB74HPBIx5auZn+nlm5/99+++/256Fidr71PF99bwoSRXM/9B6/Q4CFT0AAlRk4RGUiix1JNIJAGJRXB0cPBLcHgYAEL4iOV505uMa5pA/gN/zgWPINUZYQsRA1MlHZ+EOap3SRJQKYlg5n+Q4onIScHoeyeMEjQiBLb0PcK50ESjiccfFYRaCr4KUyQQdrtJAfmWhCkoTT9u2Md6cXBkvAgawb2i4Nf+oYdnGAm9MeblXlYOckpsNmT8DTYtApKupUhB6s0NLEvhi9j3grZc0BWsxSwZox+/cf32yPcuM8bIPYM6XFZcQy0k/AocJNEQXxOtQXKDAbkfjvaOLvNZacP8YJX53oKsfwe+0g8zH7/63jldQ1xRSgs+copFiUJaZtBjoa11GjQx3Rrpa/ok/g/yfkF2tV6LJ5CV2lORoeTzMSSN4IUYGDf5JdzfruUiWb26jroT7C6eDtAleaSrvJaGIH3vBljOoR5oWjTQiTkQdxbLuRTJjWDlUWme3IUik3miRO/jWyJXoMedyhOlRERzS6xjeTfUBc947G03qchJ5Q6mJWOapoxGqHzm/+TEahCx8sJCtGLThj30u23jip8CAw3eSVTcMHOiIhK7ucK4xG0KdhqQ5qgThjej0pJQrt22RHlEU8K2Gt+RGtnOjFU1fvfJKaTATSfamocxilv17VpQK+rEa1d4poFVU+4FgDIaJUC2rDBUWGun2oxECLprMU4eTTm7xeGUWBvGhAz6IIqK7Uhb3rQh7KNqMfUf5m54dx6k2ujGXidHO8+OBWLHrnsE2i72dI06ac1oGBSzYTVDBgND5HRB0hT7szVUlhQvLCbK+Zvw+WNcUmAEkeqZ5mpra014oZMVdJ6iarT0nEqlT4km98R08nmcOGyjSrTS5VSqm7Sq6ioR890WK6fryWD1NEE8R78S0wzymaUv3a5sPtcTRmTPjDQXLEv4cGMali6mHlu+oLgI06BjvNN6nBA5Lbsd9FEpKU/R/ulw59VRmegX+6+TMIRQjpE2REl6BkYxRrYwCtJ4jHKMtDFK0niMfEhsBdMQxsu3LkgbZ+vN+coF7rTkLkutvW7NnRY8Ldvh7mXf6Y8Fi+9hoB5pbHpjuFEakolhmIR/sjmj6G/DsCCcLkHpW/EH4M14dHB41HlpsMcCHygVs692i6fG/50r5DO3Knun5I9ERg9E/pCQ9Y/f9jL+VcVqx069ZILol63U+0G0NupBh565Nb8Ip2czzjO5VynuvYFa4/e/viO2J+891t69lsxtA+GrLJbf0B7pzvIjd8ntq2Rx4838+N5kuSjuLatU36o5uGj2Yffveq++hDrR6CwRu3ZPZ199nSXTnVywjqw/M7CIFV01EOavDQ5Rq4Jqngu+FFU1dyyqWDp9bwGaxFheJ1LTJYk0Po5Aqfz14yfCMmQ5S+4hvuBXmU4zjS5Dcs9ab4zNgdimP9+k2zZPr9L8TeGXcAHNpOgCXPEPGWVxbfd5T8MegDAnrbyuTS61ubZXmxrpUvCRQGX46gZxC0nKEExd8ZA8wrBtu2PYjtj0lJKVJIkqMRp5/InlFyfrd/8AeMaNtY4bAAA= + + + dbo + + \ No newline at end of file diff --git a/Browar/Browar/Migrations/201410181403110_Initial2.Designer.cs b/Browar/Browar/Migrations/201410181403110_Initial2.Designer.cs new file mode 100644 index 0000000..b89a53b --- /dev/null +++ b/Browar/Browar/Migrations/201410181403110_Initial2.Designer.cs @@ -0,0 +1,29 @@ +// +namespace Browar.Migrations +{ + using System.CodeDom.Compiler; + using System.Data.Entity.Migrations; + using System.Data.Entity.Migrations.Infrastructure; + using System.Resources; + + [GeneratedCode("EntityFramework.Migrations", "6.0.0-20911")] + public sealed partial class Initial2 : IMigrationMetadata + { + private readonly ResourceManager Resources = new ResourceManager(typeof(Initial2)); + + string IMigrationMetadata.Id + { + get { return "201410181403110_Initial2"; } + } + + string IMigrationMetadata.Source + { + get { return null; } + } + + string IMigrationMetadata.Target + { + get { return Resources.GetString("Target"); } + } + } +} diff --git a/Browar/Browar/Migrations/201410181403110_Initial2.cs b/Browar/Browar/Migrations/201410181403110_Initial2.cs new file mode 100644 index 0000000..e39e1b0 --- /dev/null +++ b/Browar/Browar/Migrations/201410181403110_Initial2.cs @@ -0,0 +1,70 @@ +namespace Browar.Migrations +{ + using System; + using System.Data.Entity.Migrations; + + public partial class Initial2 : DbMigration + { + public override void Up() + { + CreateTable( + "dbo.Comments", + c => new + { + Id = c.Int(nullable: false, identity: true), + Text = c.String(nullable: false), + UserId = c.Int(nullable: false), + PiwoId = c.Int(nullable: false), + }) + .PrimaryKey(t => t.Id) + .ForeignKey("dbo.Piwoes", t => t.PiwoId, cascadeDelete: true) + .ForeignKey("dbo.Users", t => t.UserId, cascadeDelete: true) + .Index(t => t.PiwoId) + .Index(t => t.UserId); + + CreateTable( + "dbo.Users", + c => new + { + Id = c.Int(nullable: false, identity: true), + Name = c.String(nullable: false), + Login = c.String(), + Password = c.String(), + Mail = c.String(), + Age = c.Int(nullable: false), + }) + .PrimaryKey(t => t.Id); + + CreateTable( + "dbo.Rates", + c => new + { + Id = c.Int(nullable: false, identity: true), + Value = c.Int(nullable: false), + UserId = c.Int(nullable: false), + PiwoId = c.Int(nullable: false), + }) + .PrimaryKey(t => t.Id) + .ForeignKey("dbo.Piwoes", t => t.PiwoId, cascadeDelete: true) + .ForeignKey("dbo.Users", t => t.UserId, cascadeDelete: true) + .Index(t => t.PiwoId) + .Index(t => t.UserId); + + } + + public override void Down() + { + DropForeignKey("dbo.Rates", "UserId", "dbo.Users"); + DropForeignKey("dbo.Rates", "PiwoId", "dbo.Piwoes"); + DropForeignKey("dbo.Comments", "UserId", "dbo.Users"); + DropForeignKey("dbo.Comments", "PiwoId", "dbo.Piwoes"); + DropIndex("dbo.Rates", new[] { "UserId" }); + DropIndex("dbo.Rates", new[] { "PiwoId" }); + DropIndex("dbo.Comments", new[] { "UserId" }); + DropIndex("dbo.Comments", new[] { "PiwoId" }); + DropTable("dbo.Rates"); + DropTable("dbo.Users"); + DropTable("dbo.Comments"); + } + } +} diff --git a/Browar/Browar/Migrations/201410181403110_Initial2.resx b/Browar/Browar/Migrations/201410181403110_Initial2.resx new file mode 100644 index 0000000..21230bc --- /dev/null +++ b/Browar/Browar/Migrations/201410181403110_Initial2.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + H4sIAAAAAAAEAO1c227cNhB9L9B/EPTUFsjKdl7aYDeB40thNL7A6+Q1oCXumqhEqhLXl2/LQz+pv1BS1IUUSd32prh9CWyKM5wZHg6H5HH++fb39MNzFDqPMEkRwTP3cHLgOhD7JEB4OXNXdPHmV/fD+x9/mJ4F0bPzpej3lvdjkjiduQ+Uxu88L/UfYATSSYT8hKRkQSc+iTwQEO/o4OA37/DQg0yFy3Q5zvR2hSmKYPYL+/WEYB/GdAXCSxLAMM3b2Zd5ptW5AhFMY+DDmfsxIU8gmYiOrnMcIsCMmMNw4ToAY0IBZSa++5zCOU0IXs5j1gDCu5cYsn4LEKYwN/1d1b2rFwdH3AuvEhwUBbf0j3l4xiJBX7h5mZeFgxgBuRvr+Ad8URpY001CYpjQl1u4yIUvAtfxVDmvLliKSTJ8fPYTpm+PXOdqFYbgPoRluKS4zilJ4O8QwwRQGNwASmGCuQ6Y+aGNXhuL/1uMxuaHocx1LsHzJ4iX9GHmsh9d5xw9w6BoyS34jBEDJROiyQoaLJRHnXpVTBsjfUKiiJn9GuN8B5/ptuOsj8oWXdLuZbOOG/REeuu4Ao9omQXOoM11bmGYfUwfUCxyxSSf+6+iw3lColsSVpjI2r/OySrxOV6J4eMdSJaQdjeFB6fRFNFBN4W3W03JPppM6bwKsgi8wiWwi1RjgC954rMohj0lKybZX0eCfLimDha3ZBPuN49yES23Pka5H24uK1RbrGk9Zqtb6lKtSPWLtiZrn9dalVky+H9VbmhVfiJLhLeO1BuQpk8kCbY+0CVA4dYHOV7CPuutM7JvGW5eI7K/gHDVK2Lfdf3EZ1ErnspGLTVWXzZWNmUq6zVT2Wi2oHe1dJymxEfZ0FJEvtrOaGc4cJq3CrFmi22GLdtVSFEcIp8NPnN/0eJi1Vh4IWmU9ixV7aFbX17X+BSGkELn2Bfn3xOQ+iDQkcHiEqgtbEXChC8JELJze0oTgDDVly/CPopB2Gh8TarjsudWlfrrX05hDDFfsY3z0GVgpe7QLSgHqsWrLTxTT8JUM9SUM4oNFuYDSwWK4pDbA2nGY04LcvcPMZPVOwCYKf5dhi3y9F6RZagydRio6XQjyFLysKRSpPOxIku2eofIkuPfZdiiitgLsqq6wIYBQ5FQASArDnsASq8rRp+nNJN3ACUt5qPPUFV11zj1ttw0CEffV1bSTN4Vjkacj0QRz2Qok4CJUsnxVn4rXocAl5hDWq/6UtepjgR6ga0hSVWT526TknLbbFHBlx80KRBprUWaB90kLLDcIsyn2SQsVlVNWJoK1Xj5Dk3qZL5lq2Oj9SRV2lxFSgNY6+FJUiJPfH3Bqi52cF99XdCdt1f27bW9ZHOFsgbXjdV8a/TWcFpAzO60ntXby86hTispXVKSL4+1fZauQXSHLbVQSzUkWZmvwwY/9fpnGzMrXbVYvGyZU32v7u/lpqayuOopd4ny29QTdIO8YepZeAnTSxDHCC8lnkLe4swFSeHkzbw/MyASOjw/NRAESmvLkShJwBLWvnLkB/AcJSk9BRTcA37ZdxJEWrdOe2IxlrY16lNV7BSFCP9ZFssJGxNrxq+CeM784os3cxGaUrQu63CqCAhBYrgAPiHhKsL2+scuLR4rZHnRomuYejXjtVpHC5FWFKpB7zQlZS4cPiFGEkSn6bBKbmcyBKVBlhct3TUUhaisw1ac2rUUxyJZi+2otDdg5Kl/OCxM21YHTJjF9r06rVMpHuuVmRRNPXSIx3pFh2jqriN/rJd15E3ddWRP8UoweUN3eeW6W9bTeA++N4CLXX84vk0FSwd8m8XGiu/82VtWkTf1wHf5qK1AvGztrkm8WstaREt3DdmTtKwgaxgNJkUhOxyT+st4pqANk2ax7WAyf+SWFeRN/+FtWDtR1LuUo5cni9oJYppX8+30Z628F11ch4XnEQW8tJ+/pBRGE95hMv8rPAlRdt1UdLgEGC1gSu/In5Cd4Y4ODo9qNOoBlGYvTYNwtLxmxP1vpXf0JFrITCb8CBL/ASQ/ReD55++enryVcMmM5D7h0jWpLJnM2LU4Mu0aRs6lHRW8DdGWKbGLkIABEyYzYoepUAixVod6kl7X0mMgtm4QivshkI4cigoPdK3Jq3M911Im8znXUiRxNjcIpf0wNrcCJYWkOWTrGM/mM5iaKD3L7Zw8qL7IDeBDDnoqb7p03grj8DURDDtN1JZAUr6VD6GdDSaq7pDcNX4iTieqoHgb3CVlZp8Ysdwd7hUjIyf97TOJCNZKb3LYqNOH5apwZLmjncS3z8SxS1zsKmV0xsXeSXk6T6E+TxZiXjMvT1yHztzgnucbUVQ3ULssvL0m2p5pBBsnyUjqs1L6TJotHB4T3c/K9jPpNbNmTERAKw/QpNbI5dk6RVDDRo0u0sYM1FhT46EAdjLPXA8ZqBqjIfnJeK0eVvfn1to8vv7zJK+t6h1vBGS9/nOzris9KHn6QxnbmaT/TYjtiClaVir4/y2Eoa/sSWWfC7wgxdZYs6joUr+pgxQEbMM6TihaAJ+yzz5M0+wvsLO7pZl7Ft3D4AJfr2i8osxlGN2Hyh8P8y22afyMd6jaPL2Os79+3YQLzEzEXIDX+OMKhUFp97nh6smigu/d+aUcn0vKL+eWL6WmK4I7KsrDV5YcdzCKQ76FXOM5eIR229pjqEZseorAMgFRmuuo5NmvDH5B9Pz+X0cuT14PSwAA + + + dbo + + \ No newline at end of file diff --git a/Browar/Browar/Migrations/Configuration.cs b/Browar/Browar/Migrations/Configuration.cs index a92da8d..284c33d 100644 --- a/Browar/Browar/Migrations/Configuration.cs +++ b/Browar/Browar/Migrations/Configuration.cs @@ -18,8 +18,23 @@ protected override void Seed(Browar.Models.BrowarContext context) context.Browarnias.AddOrUpdate(x => x.Id, new Browarnia() { Id = 1, Name = "Lech" }, new Browarnia() { Id = 2, Name = "Bosman" }, - new Browarnia() { Id = 3, Name = "Okocim" } - ); + new Browarnia() { Id = 3, Name = "Okocim" }); + + context.Users.AddOrUpdate(x => x.Id, + new User() { Id = 1, Name = "Dariusz", Login = "daro", Password = "qwerty", Mail = "darospeed1992@gmail.com", Age = 22 }, + new User() { Id = 2, Name = "Maciej", Login = "maciej", Password = "qwerty", Mail = "m@gmail.com", Age = 22}, + new User() { Id = 3, Name = "Patryk", Login = "patryk", Password = "qwerty", Mail = "p@gmail.com", Age = 22}); + + context.Rates.AddOrUpdate(x => x.Id, + new Rate() { Id = 1, PiwoId = 1, UserId = 1, Value = 7 }, + new Rate() { Id = 2, PiwoId = 2, UserId = 2, Value = 8 }, + new Rate() { Id = 3, PiwoId = 4, UserId = 3, Value = 5 }); + + context.Comments.AddOrUpdate(x => x.Id, + new Comment() { Id = 1, PiwoId = 1, UserId = 1, Text = "Sch³odzone jest nawet spoko." }, + new Comment() { Id = 2, PiwoId = 2, UserId = 2, Text = "Dzieñ bez zimnego lecha jest dniem straconym." }, + new Comment() { Id = 3, PiwoId = 4, UserId = 3, Text = "To zdecydowanie babskie piwo." }); + context.Piwoes.AddOrUpdate(x => x.Id, new Piwo() @@ -29,7 +44,8 @@ protected override void Seed(Browar.Models.BrowarContext context) Power = 5.6, BrowarniaId = 2, Price = 2.00, - Genre = "Lager" + Genre = "Lager", + Img = string.Empty }, new Piwo() { @@ -38,7 +54,8 @@ protected override void Seed(Browar.Models.BrowarContext context) Power = 5.2, BrowarniaId = 1, Price = 3.00, - Genre = "Lager" + Genre = "Lager", + Img = string.Empty }, new Piwo() { @@ -47,7 +64,8 @@ protected override void Seed(Browar.Models.BrowarContext context) Power = 5.8, BrowarniaId = 3, Price = 2.80, - Genre = "Lager" + Genre = "Lager", + Img = string.Empty }, new Piwo() { @@ -56,9 +74,8 @@ protected override void Seed(Browar.Models.BrowarContext context) Power = 2.0, BrowarniaId = 3, Price = 3.30, - Genre = "Dark lager" - } - ); + Genre = "Dark lager", + Img = string.Empty }); } } } diff --git a/Browar/Browar/Models/BrowarContext.cs b/Browar/Browar/Models/BrowarContext.cs index 65c0bcb..6b29f32 100644 --- a/Browar/Browar/Models/BrowarContext.cs +++ b/Browar/Browar/Models/BrowarContext.cs @@ -22,6 +22,12 @@ public BrowarContext() : base("name=BrowarContext") public System.Data.Entity.DbSet Browarnias { get; set; } public System.Data.Entity.DbSet Piwoes { get; set; } + + public System.Data.Entity.DbSet Users { get; set; } + + public System.Data.Entity.DbSet Comments { get; set; } + + public System.Data.Entity.DbSet Rates { get; set; } } } diff --git a/Browar/Browar/Models/BrowarniaDTO.cs b/Browar/Browar/Models/BrowarniaDTO.cs new file mode 100644 index 0000000..d46c5db --- /dev/null +++ b/Browar/Browar/Models/BrowarniaDTO.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace Browar.Models +{ + public class BrowarniaDTO + { + public int Id { get; set; } + public string Name { get; set; } + } +} \ No newline at end of file diff --git a/Browar/Browar/Models/BrowarniaDetailDTO.cs b/Browar/Browar/Models/BrowarniaDetailDTO.cs new file mode 100644 index 0000000..4293f5a --- /dev/null +++ b/Browar/Browar/Models/BrowarniaDetailDTO.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace Browar.Models +{ + public class BrowarniaDetailDTO + { + public int Id { get; set; } + public string Name { get; set; } + } +} \ No newline at end of file diff --git a/Browar/Browar/Models/Comment.cs b/Browar/Browar/Models/Comment.cs new file mode 100644 index 0000000..f2d967b --- /dev/null +++ b/Browar/Browar/Models/Comment.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace Browar.Models +{ + using System.ComponentModel.DataAnnotations; + + public class Comment + { + public int Id { get; set; } + [Required] + public string Text { get; set; } + + // Klucze obce + public int UserId { get; set; } + public User User { get; set; } + + public int PiwoId { get; set; } + public Piwo Piwo { get; set; } + } +} \ No newline at end of file diff --git a/Browar/Browar/Models/Piwo.cs b/Browar/Browar/Models/Piwo.cs index 9962f3c..b02b8cc 100644 --- a/Browar/Browar/Models/Piwo.cs +++ b/Browar/Browar/Models/Piwo.cs @@ -15,6 +15,7 @@ public class Piwo public double Power { get; set; } public double Price { get; set; } public string Genre { get; set; } + public string Img { get; set; } // Foreign Key public int BrowarniaId { get; set; } diff --git a/Browar/Browar/Models/Rate.cs b/Browar/Browar/Models/Rate.cs new file mode 100644 index 0000000..b6d214c --- /dev/null +++ b/Browar/Browar/Models/Rate.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace Browar.Models +{ + using System.ComponentModel.DataAnnotations; + + public class Rate + { + public int Id { get; set; } + [Required] + public int Value { get; set; } + + // Klucze obce + public int UserId { get; set; } + public User User { get; set; } + + public int PiwoId { get; set; } + public Piwo Piwo { get; set; } + } +} \ No newline at end of file diff --git a/Browar/Browar/Models/User.cs b/Browar/Browar/Models/User.cs new file mode 100644 index 0000000..b741511 --- /dev/null +++ b/Browar/Browar/Models/User.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace Browar.Models +{ + using System.ComponentModel.DataAnnotations; + + public class User + { + public int Id { get; set; } + [Required] + public string Name { get; set; } + public string Login { get; set; } + public string Password { get; set; } + public string Mail { get; set; } + public int Age { get; set; } + } +} \ No newline at end of file diff --git a/Browar/Browar/Scripts/app.js b/Browar/Browar/Scripts/app.js index 6899f68..526e2d3 100644 --- a/Browar/Browar/Scripts/app.js +++ b/Browar/Browar/Scripts/app.js @@ -1,12 +1,16 @@ var ViewModel = function () { var self = this; self.piwoes = ko.observableArray(); + self.browarnias = ko.observableArray(); self.error = ko.observable(); + self.piwoDetail = ko.observable(); + self.browarniaDetail = ko.observable(); var piwoesUri = '/api/Piwoes/'; + var browarniasUri = '/api/Browarnias/'; function ajaxHelper(uri, method, data) { - self.error(''); // Clear error message + self.error(''); return $.ajax({ type: method, url: uri, @@ -24,16 +28,25 @@ }); } - self.detail = ko.observable(); + function getAllBrowarnias() { + ajaxHelper(browarniasUri, 'GET').done(function (data) { + self.browarnias(data); + }); + } - self.getPiwoDetail = function (item) { + self.getPiwoDetail = function (item) { ajaxHelper(piwoesUri + item.Id, 'GET').done(function (data) { - self.detail(data); + self.piwoDetail(data); }); - } + } - self.browarnias = ko.observableArray(); - self.newPiwo = { + self.getBrowarniaDetail = function (item) { + ajaxHelper(browarniasUri + item.Id, 'GET').done(function (data) { + self.browarniaDetail(data); + }); + } + + self.newPiwo = { Browarnia: ko.observable(), Genre: ko.observable(), Price: ko.observable(), @@ -41,15 +54,7 @@ Power: ko.observable() } - var browarniasUri = '/api/Browarnias/'; - - function getBrowarnias() { - ajaxHelper(browarniasUri, 'GET').done(function (data) { - self.browarnias(data); - }); - } - - self.addPiwo = function (formElement) { + self.addPiwo = function (formElement) { var piwo = { BrowarniaId: self.newPiwo.Browarnia().Id, Genre: self.newPiwo.Genre(), @@ -61,12 +66,25 @@ ajaxHelper(piwoesUri, 'POST', piwo).done(function (item) { self.piwoes.push(item); }); - } + } + + self.newBrowarnia = { + Name: ko.observable(), + } - getBrowarnias(); + self.addBrowarnia = function (formElement) { + var browarnia = { + Name: self.newBrowarnia.Name(), + }; - // Fetch the initial data. + ajaxHelper(browarniasUri, 'POST', browarnia).done(function (item) { + self.browarnias.push(item); + }); + } + + // Inicjowanie danych. getAllPiwoes(); + getAllBrowarnias(); }; ko.applyBindings(new ViewModel()); \ No newline at end of file diff --git a/Browar/Browar/Service References/Serwer/Browar.Serwer.HelloWorldResponse.datasource b/Browar/Browar/Service References/Serwer/Browar.Serwer.HelloWorldResponse.datasource new file mode 100644 index 0000000..80332a5 --- /dev/null +++ b/Browar/Browar/Service References/Serwer/Browar.Serwer.HelloWorldResponse.datasource @@ -0,0 +1,10 @@ + + + + Browar.Serwer.HelloWorldResponse, Service References.Serwer.Reference.cs, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/Browar/Browar/Service References/Serwer/Reference.cs b/Browar/Browar/Service References/Serwer/Reference.cs new file mode 100644 index 0000000..2614ba6 --- /dev/null +++ b/Browar/Browar/Service References/Serwer/Reference.cs @@ -0,0 +1,137 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.34014 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Browar.Serwer { + + + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + [System.ServiceModel.ServiceContractAttribute(ConfigurationName="Serwer.ServiceSoap")] + public interface ServiceSoap { + + // CODEGEN: Generating message contract since element name HelloWorldResult from namespace http://tempuri.org/ is not marked nillable + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/HelloWorld", ReplyAction="*")] + Browar.Serwer.HelloWorldResponse HelloWorld(Browar.Serwer.HelloWorldRequest request); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/HelloWorld", ReplyAction="*")] + System.Threading.Tasks.Task HelloWorldAsync(Browar.Serwer.HelloWorldRequest request); + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + [System.ServiceModel.MessageContractAttribute(IsWrapped=false)] + public partial class HelloWorldRequest { + + [System.ServiceModel.MessageBodyMemberAttribute(Name="HelloWorld", Namespace="http://tempuri.org/", Order=0)] + public Browar.Serwer.HelloWorldRequestBody Body; + + public HelloWorldRequest() { + } + + public HelloWorldRequest(Browar.Serwer.HelloWorldRequestBody Body) { + this.Body = Body; + } + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + [System.Runtime.Serialization.DataContractAttribute()] + public partial class HelloWorldRequestBody { + + public HelloWorldRequestBody() { + } + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + [System.ServiceModel.MessageContractAttribute(IsWrapped=false)] + public partial class HelloWorldResponse { + + [System.ServiceModel.MessageBodyMemberAttribute(Name="HelloWorldResponse", Namespace="http://tempuri.org/", Order=0)] + public Browar.Serwer.HelloWorldResponseBody Body; + + public HelloWorldResponse() { + } + + public HelloWorldResponse(Browar.Serwer.HelloWorldResponseBody Body) { + this.Body = Body; + } + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + [System.Runtime.Serialization.DataContractAttribute(Namespace="http://tempuri.org/")] + public partial class HelloWorldResponseBody { + + [System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false, Order=0)] + public string HelloWorldResult; + + public HelloWorldResponseBody() { + } + + public HelloWorldResponseBody(string HelloWorldResult) { + this.HelloWorldResult = HelloWorldResult; + } + } + + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + public interface ServiceSoapChannel : Browar.Serwer.ServiceSoap, System.ServiceModel.IClientChannel { + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + public partial class ServiceSoapClient : System.ServiceModel.ClientBase, Browar.Serwer.ServiceSoap { + + public ServiceSoapClient() { + } + + public ServiceSoapClient(string endpointConfigurationName) : + base(endpointConfigurationName) { + } + + public ServiceSoapClient(string endpointConfigurationName, string remoteAddress) : + base(endpointConfigurationName, remoteAddress) { + } + + public ServiceSoapClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : + base(endpointConfigurationName, remoteAddress) { + } + + public ServiceSoapClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : + base(binding, remoteAddress) { + } + + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + Browar.Serwer.HelloWorldResponse Browar.Serwer.ServiceSoap.HelloWorld(Browar.Serwer.HelloWorldRequest request) { + return base.Channel.HelloWorld(request); + } + + public string HelloWorld() { + Browar.Serwer.HelloWorldRequest inValue = new Browar.Serwer.HelloWorldRequest(); + inValue.Body = new Browar.Serwer.HelloWorldRequestBody(); + Browar.Serwer.HelloWorldResponse retVal = ((Browar.Serwer.ServiceSoap)(this)).HelloWorld(inValue); + return retVal.Body.HelloWorldResult; + } + + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + System.Threading.Tasks.Task Browar.Serwer.ServiceSoap.HelloWorldAsync(Browar.Serwer.HelloWorldRequest request) { + return base.Channel.HelloWorldAsync(request); + } + + public System.Threading.Tasks.Task HelloWorldAsync() { + Browar.Serwer.HelloWorldRequest inValue = new Browar.Serwer.HelloWorldRequest(); + inValue.Body = new Browar.Serwer.HelloWorldRequestBody(); + return ((Browar.Serwer.ServiceSoap)(this)).HelloWorldAsync(inValue); + } + } +} diff --git a/Browar/Browar/Service References/Serwer/Reference.svcmap b/Browar/Browar/Service References/Serwer/Reference.svcmap new file mode 100644 index 0000000..f008b6e --- /dev/null +++ b/Browar/Browar/Service References/Serwer/Reference.svcmap @@ -0,0 +1,31 @@ + + + + false + true + true + + false + false + false + + + true + Auto + true + true + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Browar/Browar/Service References/Serwer/Service.wsdl b/Browar/Browar/Service References/Serwer/Service.wsdl new file mode 100644 index 0000000..b90470d --- /dev/null +++ b/Browar/Browar/Service References/Serwer/Service.wsdl @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Browar/Browar/Service References/Serwer/configuration.svcinfo b/Browar/Browar/Service References/Serwer/configuration.svcinfo new file mode 100644 index 0000000..6d11f81 --- /dev/null +++ b/Browar/Browar/Service References/Serwer/configuration.svcinfo @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Browar/Browar/Service References/Serwer/configuration91.svcinfo b/Browar/Browar/Service References/Serwer/configuration91.svcinfo new file mode 100644 index 0000000..666c222 --- /dev/null +++ b/Browar/Browar/Service References/Serwer/configuration91.svcinfo @@ -0,0 +1,201 @@ + + + + + + + ServiceSoap + + + + + + + + + + + + + + + + + + + + + StrongWildcard + + + + + + 65536 + + + + + + + + + System.ServiceModel.Configuration.XmlDictionaryReaderQuotasElement + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + System.Text.UTF8Encoding + + + Buffered + + + + + + Text + + + System.ServiceModel.Configuration.BasicHttpSecurityElement + + + None + + + System.ServiceModel.Configuration.HttpTransportSecurityElement + + + None + + + None + + + System.Security.Authentication.ExtendedProtection.Configuration.ExtendedProtectionPolicyElement + + + Never + + + TransportSelected + + + (Collection) + + + + + + System.ServiceModel.Configuration.BasicHttpMessageSecurityElement + + + UserName + + + Default + + + + + + + + + http://localhost:1344/Service.asmx + + + + + + basicHttpBinding + + + ServiceSoap + + + Serwer.ServiceSoap + + + System.ServiceModel.Configuration.AddressHeaderCollectionElement + + + <Header /> + + + System.ServiceModel.Configuration.IdentityElement + + + System.ServiceModel.Configuration.UserPrincipalNameElement + + + + + + System.ServiceModel.Configuration.ServicePrincipalNameElement + + + + + + System.ServiceModel.Configuration.DnsElement + + + + + + System.ServiceModel.Configuration.RsaElement + + + + + + System.ServiceModel.Configuration.CertificateElement + + + + + + System.ServiceModel.Configuration.CertificateReferenceElement + + + My + + + LocalMachine + + + FindBySubjectDistinguishedName + + + + + + False + + + ServiceSoap + + + + + + + + + + + \ No newline at end of file diff --git a/Browar/Browar/Views/Add/Index.cshtml b/Browar/Browar/Views/Add/Index.cshtml new file mode 100644 index 0000000..89de0de --- /dev/null +++ b/Browar/Browar/Views/Add/Index.cshtml @@ -0,0 +1,74 @@ +@section scripts { + @Scripts.Render("~/bundles/app") +} + + + +
+ +
+
+
+

Dodaj Piwo

+
+ +
+
+
+ +
+ +
+
+ +
+ +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+
+ +
+
+
+
+ + +
+
+
+

Dodaj Browar

+
+ +
+
+
+ +
+ +
+
+ +
+
+
+
+ +
\ No newline at end of file diff --git a/Browar/Browar/Views/Home/Index.cshtml b/Browar/Browar/Views/Home/Index.cshtml index 0202b3b..2bd48f4 100644 --- a/Browar/Browar/Views/Home/Index.cshtml +++ b/Browar/Browar/Views/Home/Index.cshtml @@ -16,7 +16,7 @@
@@ -25,7 +25,8 @@

- + +
@@ -33,18 +34,18 @@

Szczegóły

- - - - - + + + + +
Browar
Nazwa
Moc
Gatunek
Cena
Browar
Nazwa
Moc
Gatunek
Cena
- -
+ + @*

Dodaj Piwo

@@ -77,14 +78,71 @@
- +
+
*@ + + + +
+ +
+
+
+

Browary

+
+
+ +
+
+

- + + + +
+
+
+

Szczegóły

+
+ + + +
Id
Nazwa
+
+
+ + + + @*
+
+
+

Dodaj Browar

+
+ +
+
+
+ +
+ +
+
+ +
+
+
+
*@ +
\ No newline at end of file diff --git a/Browar/Browar/Views/Shared/_Layout.cshtml b/Browar/Browar/Views/Shared/_Layout.cshtml index f37e8fc..b33f7ec 100644 --- a/Browar/Browar/Views/Shared/_Layout.cshtml +++ b/Browar/Browar/Views/Shared/_Layout.cshtml @@ -16,12 +16,11 @@ - @Html.ActionLink("Application name", "Index", "Home", new { area = "" }, new { @class = "navbar-brand" }) diff --git a/Browar/Browar/Web.config b/Browar/Browar/Web.config index 4e198c0..eabc51b 100644 --- a/Browar/Browar/Web.config +++ b/Browar/Browar/Web.config @@ -22,7 +22,7 @@ - + @@ -63,4 +63,16 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Browar/Browar/bin/Browar.dll b/Browar/Browar/bin/Browar.dll index 8316fc7..46c33a2 100644 Binary files a/Browar/Browar/bin/Browar.dll and b/Browar/Browar/bin/Browar.dll differ diff --git a/Browar/Browar/bin/Browar.dll.config b/Browar/Browar/bin/Browar.dll.config index 4e198c0..eabc51b 100644 --- a/Browar/Browar/bin/Browar.dll.config +++ b/Browar/Browar/bin/Browar.dll.config @@ -22,7 +22,7 @@ - + @@ -63,4 +63,16 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Browar/Browar/bin/Browar.pdb b/Browar/Browar/bin/Browar.pdb index a944785..32de843 100644 Binary files a/Browar/Browar/bin/Browar.pdb and b/Browar/Browar/bin/Browar.pdb differ diff --git a/Browar/Browar/obj/Debug/Browar.Migrations.Initial1.resources b/Browar/Browar/obj/Debug/Browar.Migrations.Initial1.resources new file mode 100644 index 0000000..d01ce9b Binary files /dev/null and b/Browar/Browar/obj/Debug/Browar.Migrations.Initial1.resources differ diff --git a/Browar/Browar/obj/Debug/Browar.Migrations.Initial2.resources b/Browar/Browar/obj/Debug/Browar.Migrations.Initial2.resources new file mode 100644 index 0000000..596e866 Binary files /dev/null and b/Browar/Browar/obj/Debug/Browar.Migrations.Initial2.resources differ diff --git a/Browar/Browar/obj/Debug/Browar.csproj.FileListAbsolute.txt b/Browar/Browar/obj/Debug/Browar.csproj.FileListAbsolute.txt index 8b5f0e4..b2af238 100644 --- a/Browar/Browar/obj/Debug/Browar.csproj.FileListAbsolute.txt +++ b/Browar/Browar/obj/Debug/Browar.csproj.FileListAbsolute.txt @@ -33,6 +33,8 @@ c:\users\dariusz\documents\visual studio 2013\Projects\Browar\Browar\bin\EntityF c:\users\dariusz\documents\visual studio 2013\Projects\Browar\Browar\bin\EntityFramework.SqlServer.dll c:\users\dariusz\documents\visual studio 2013\Projects\Browar\Browar\bin\EntityFramework.xml c:\users\dariusz\documents\visual studio 2013\Projects\Browar\Browar\bin\EntityFramework.SqlServer.xml -C:\Users\Dariusz\documents\visual studio 2013\Projects\Browar\Browar\obj\Debug\Browar.csprojResolveAssemblyReference.cache C:\Users\Dariusz\documents\visual studio 2013\Projects\Browar\Browar\obj\Debug\Browar.Migrations.Initial.resources C:\Users\Dariusz\documents\visual studio 2013\Projects\Browar\Browar\obj\Debug\Browar.csproj.GenerateResource.Cache +C:\Users\Dariusz\documents\visual studio 2013\Projects\Browar\Browar\obj\Debug\Browar.Migrations.Initial1.resources +C:\Users\Dariusz\documents\visual studio 2013\Projects\Browar\Browar\obj\Debug\Browar.Migrations.Initial2.resources +C:\Users\Dariusz\documents\visual studio 2013\Projects\Browar\Browar\obj\Debug\Browar.csprojResolveAssemblyReference.cache diff --git a/Browar/Browar/obj/Debug/Browar.csproj.GenerateResource.Cache b/Browar/Browar/obj/Debug/Browar.csproj.GenerateResource.Cache index 6b72a1d..cd04ff1 100644 Binary files a/Browar/Browar/obj/Debug/Browar.csproj.GenerateResource.Cache and b/Browar/Browar/obj/Debug/Browar.csproj.GenerateResource.Cache differ diff --git a/Browar/Browar/obj/Debug/Browar.csprojResolveAssemblyReference.cache b/Browar/Browar/obj/Debug/Browar.csprojResolveAssemblyReference.cache index 15a8e14..15d4a09 100644 Binary files a/Browar/Browar/obj/Debug/Browar.csprojResolveAssemblyReference.cache and b/Browar/Browar/obj/Debug/Browar.csprojResolveAssemblyReference.cache differ diff --git a/Browar/Browar/obj/Debug/Browar.dll b/Browar/Browar/obj/Debug/Browar.dll index 8316fc7..46c33a2 100644 Binary files a/Browar/Browar/obj/Debug/Browar.dll and b/Browar/Browar/obj/Debug/Browar.dll differ diff --git a/Browar/Browar/obj/Debug/Browar.pdb b/Browar/Browar/obj/Debug/Browar.pdb index a944785..32de843 100644 Binary files a/Browar/Browar/obj/Debug/Browar.pdb and b/Browar/Browar/obj/Debug/Browar.pdb differ diff --git a/Browar/Browar/obj/Debug/DesignTimeResolveAssemblyReferences.cache b/Browar/Browar/obj/Debug/DesignTimeResolveAssemblyReferences.cache new file mode 100644 index 0000000..fc13138 Binary files /dev/null and b/Browar/Browar/obj/Debug/DesignTimeResolveAssemblyReferences.cache differ diff --git a/Browar/Browar/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/Browar/Browar/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache index f532357..8efe195 100644 Binary files a/Browar/Browar/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache and b/Browar/Browar/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/Browar/Browar/obj/Debug/TempPE/Service References.Serwer.Reference.cs.dll b/Browar/Browar/obj/Debug/TempPE/Service References.Serwer.Reference.cs.dll new file mode 100644 index 0000000..93c354f Binary files /dev/null and b/Browar/Browar/obj/Debug/TempPE/Service References.Serwer.Reference.cs.dll differ diff --git a/Browar/Browar/obj/Release/DesignTimeResolveAssemblyReferencesInput.cache b/Browar/Browar/obj/Release/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..1b6b74e Binary files /dev/null and b/Browar/Browar/obj/Release/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/Browar/Browar/obj/Release/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs b/Browar/Browar/obj/Release/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs new file mode 100644 index 0000000..e69de29 diff --git a/Browar/Browar/obj/Release/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs b/Browar/Browar/obj/Release/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs new file mode 100644 index 0000000..e69de29 diff --git a/Browar/Browar/obj/Release/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs b/Browar/Browar/obj/Release/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs new file mode 100644 index 0000000..e69de29 diff --git a/Browar/Serwer/Properties/AssemblyInfo.cs b/Browar/Serwer/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..9d1183e --- /dev/null +++ b/Browar/Serwer/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Serwer")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Serwer")] +[assembly: AssemblyCopyright("Copyright © 2014")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("1f7b7025-3c3e-471d-838a-191aa75c77fc")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Browar/Serwer/Properties/PublishProfiles/TASy.pubxml b/Browar/Serwer/Properties/PublishProfiles/TASy.pubxml new file mode 100644 index 0000000..08883a5 --- /dev/null +++ b/Browar/Serwer/Properties/PublishProfiles/TASy.pubxml @@ -0,0 +1,23 @@ + + + + + MSDeploy + Release + Any CPU + + True + False + localhost + Default Web Site/MyApplication/Browar/Serwer/Service.asmx + + True + InProc + False + + <_SavePWD>False + + \ No newline at end of file diff --git a/Browar/Serwer/Properties/PublishProfiles/TASy.pubxml.user b/Browar/Serwer/Properties/PublishProfiles/TASy.pubxml.user new file mode 100644 index 0000000..0408111 --- /dev/null +++ b/Browar/Serwer/Properties/PublishProfiles/TASy.pubxml.user @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/Browar/Serwer/Service.asmx b/Browar/Serwer/Service.asmx new file mode 100644 index 0000000..f0c2d29 --- /dev/null +++ b/Browar/Serwer/Service.asmx @@ -0,0 +1 @@ +<%@ WebService Language="C#" CodeBehind="Service.asmx.cs" Class="Serwer.Service" %> diff --git a/Browar/Serwer/Service.asmx.cs b/Browar/Serwer/Service.asmx.cs new file mode 100644 index 0000000..656caf0 --- /dev/null +++ b/Browar/Serwer/Service.asmx.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.Services; + +namespace Serwer +{ + /// + /// Summary description for Service + /// + [WebService(Namespace = "http://tempuri.org/")] + [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] + [System.ComponentModel.ToolboxItem(false)] + // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. + // [System.Web.Script.Services.ScriptService] + public class Service : System.Web.Services.WebService + { + + [WebMethod] + public string HelloWorld() + { + return "Hello World"; + } + } +} diff --git a/Browar/Serwer/Serwer.csproj b/Browar/Serwer/Serwer.csproj new file mode 100644 index 0000000..080c00c --- /dev/null +++ b/Browar/Serwer/Serwer.csproj @@ -0,0 +1,111 @@ + + + + + Debug + AnyCPU + + + 2.0 + {BDE37148-3388-432D-9BA7-595915F45AAD} + {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} + Library + Properties + Serwer + Serwer + v4.5 + true + + + + + + + true + full + false + bin\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + + Web.config + + + Web.config + + + + + + + + + + Service.asmx + Component + + + + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + + + + + + True + True + 1678 + / + http://localhost:1344/ + False + False + + + False + + + + + + \ No newline at end of file diff --git a/Browar/Serwer/Serwer.csproj.user b/Browar/Serwer/Serwer.csproj.user new file mode 100644 index 0000000..845979c --- /dev/null +++ b/Browar/Serwer/Serwer.csproj.user @@ -0,0 +1,31 @@ + + + + TASy + + + + + + + + CurrentPage + True + False + False + False + + + + + + + + + True + True + + + + + \ No newline at end of file diff --git a/Browar/Serwer/Web.Debug.config b/Browar/Serwer/Web.Debug.config new file mode 100644 index 0000000..2e302f9 --- /dev/null +++ b/Browar/Serwer/Web.Debug.config @@ -0,0 +1,30 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Browar/Serwer/Web.Release.config b/Browar/Serwer/Web.Release.config new file mode 100644 index 0000000..c358444 --- /dev/null +++ b/Browar/Serwer/Web.Release.config @@ -0,0 +1,31 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Browar/Serwer/Web.config b/Browar/Serwer/Web.config new file mode 100644 index 0000000..bfb640d --- /dev/null +++ b/Browar/Serwer/Web.config @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/Browar/Serwer/bin/Serwer.dll b/Browar/Serwer/bin/Serwer.dll new file mode 100644 index 0000000..2faf02a Binary files /dev/null and b/Browar/Serwer/bin/Serwer.dll differ diff --git a/Browar/Serwer/bin/Serwer.dll.config b/Browar/Serwer/bin/Serwer.dll.config new file mode 100644 index 0000000..bfb640d --- /dev/null +++ b/Browar/Serwer/bin/Serwer.dll.config @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/Browar/Serwer/bin/Serwer.pdb b/Browar/Serwer/bin/Serwer.pdb new file mode 100644 index 0000000..f590c2e Binary files /dev/null and b/Browar/Serwer/bin/Serwer.pdb differ diff --git a/Browar/Serwer/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/Browar/Serwer/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..0304774 Binary files /dev/null and b/Browar/Serwer/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/Browar/Serwer/obj/Debug/Serwer.csproj.FileListAbsolute.txt b/Browar/Serwer/obj/Debug/Serwer.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..487e37c --- /dev/null +++ b/Browar/Serwer/obj/Debug/Serwer.csproj.FileListAbsolute.txt @@ -0,0 +1,5 @@ +C:\Users\Dariusz\documents\visual studio 2013\Projects\Browar\Serwer\bin\Serwer.dll.config +C:\Users\Dariusz\documents\visual studio 2013\Projects\Browar\Serwer\bin\Serwer.dll +C:\Users\Dariusz\documents\visual studio 2013\Projects\Browar\Serwer\bin\Serwer.pdb +C:\Users\Dariusz\documents\visual studio 2013\Projects\Browar\Serwer\obj\Debug\Serwer.dll +C:\Users\Dariusz\documents\visual studio 2013\Projects\Browar\Serwer\obj\Debug\Serwer.pdb diff --git a/Browar/Serwer/obj/Debug/Serwer.dll b/Browar/Serwer/obj/Debug/Serwer.dll new file mode 100644 index 0000000..2faf02a Binary files /dev/null and b/Browar/Serwer/obj/Debug/Serwer.dll differ diff --git a/Browar/Serwer/obj/Debug/Serwer.pdb b/Browar/Serwer/obj/Debug/Serwer.pdb new file mode 100644 index 0000000..f590c2e Binary files /dev/null and b/Browar/Serwer/obj/Debug/Serwer.pdb differ diff --git a/Browar/Serwer/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs b/Browar/Serwer/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs new file mode 100644 index 0000000..e69de29 diff --git a/Browar/Serwer/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs b/Browar/Serwer/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs new file mode 100644 index 0000000..e69de29 diff --git a/Browar/Serwer/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs b/Browar/Serwer/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs new file mode 100644 index 0000000..e69de29 diff --git a/Browar/Serwer/obj/Debug/__TestProfilesForFilePreview__/TASy.pubxml b/Browar/Serwer/obj/Debug/__TestProfilesForFilePreview__/TASy.pubxml new file mode 100644 index 0000000..08883a5 --- /dev/null +++ b/Browar/Serwer/obj/Debug/__TestProfilesForFilePreview__/TASy.pubxml @@ -0,0 +1,23 @@ + + + + + MSDeploy + Release + Any CPU + + True + False + localhost + Default Web Site/MyApplication/Browar/Serwer/Service.asmx + + True + InProc + False + + <_SavePWD>False + + \ No newline at end of file diff --git a/Browar/Serwer/obj/Release/CSAutoParameterize.parameters.xml b/Browar/Serwer/obj/Release/CSAutoParameterize.parameters.xml new file mode 100644 index 0000000..560a540 --- /dev/null +++ b/Browar/Serwer/obj/Release/CSAutoParameterize.parameters.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/Browar/Serwer/obj/Release/CSAutoParameterize/original/Web.config b/Browar/Serwer/obj/Release/CSAutoParameterize/original/Web.config new file mode 100644 index 0000000..4aaef7c --- /dev/null +++ b/Browar/Serwer/obj/Release/CSAutoParameterize/original/Web.config @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/Browar/Serwer/obj/Release/CSAutoParameterize/transformed/Web.config b/Browar/Serwer/obj/Release/CSAutoParameterize/transformed/Web.config new file mode 100644 index 0000000..4aaef7c --- /dev/null +++ b/Browar/Serwer/obj/Release/CSAutoParameterize/transformed/Web.config @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/Browar/Serwer/obj/Release/DesignTimeResolveAssemblyReferencesInput.cache b/Browar/Serwer/obj/Release/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..3cf0e76 Binary files /dev/null and b/Browar/Serwer/obj/Release/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/Browar/Serwer/obj/Release/Package/FilePreviewParameter.xml b/Browar/Serwer/obj/Release/Package/FilePreviewParameter.xml new file mode 100644 index 0000000..ef7f4f3 --- /dev/null +++ b/Browar/Serwer/obj/Release/Package/FilePreviewParameter.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Browar/Serwer/obj/Release/Package/PackageTmp/Service.asmx b/Browar/Serwer/obj/Release/Package/PackageTmp/Service.asmx new file mode 100644 index 0000000..f0c2d29 --- /dev/null +++ b/Browar/Serwer/obj/Release/Package/PackageTmp/Service.asmx @@ -0,0 +1 @@ +<%@ WebService Language="C#" CodeBehind="Service.asmx.cs" Class="Serwer.Service" %> diff --git a/Browar/Serwer/obj/Release/Package/PackageTmp/Web.config b/Browar/Serwer/obj/Release/Package/PackageTmp/Web.config new file mode 100644 index 0000000..4aaef7c --- /dev/null +++ b/Browar/Serwer/obj/Release/Package/PackageTmp/Web.config @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/Browar/Serwer/obj/Release/Package/PackageTmp/bin/Serwer.dll b/Browar/Serwer/obj/Release/Package/PackageTmp/bin/Serwer.dll new file mode 100644 index 0000000..4ba3763 Binary files /dev/null and b/Browar/Serwer/obj/Release/Package/PackageTmp/bin/Serwer.dll differ diff --git a/Browar/Serwer/obj/Release/Package/Serwer.SourceManifest.xml b/Browar/Serwer/obj/Release/Package/Serwer.SourceManifest.xml new file mode 100644 index 0000000..849adca --- /dev/null +++ b/Browar/Serwer/obj/Release/Package/Serwer.SourceManifest.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Browar/Serwer/obj/Release/Serwer.csproj.FileListAbsolute.txt b/Browar/Serwer/obj/Release/Serwer.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..d887254 --- /dev/null +++ b/Browar/Serwer/obj/Release/Serwer.csproj.FileListAbsolute.txt @@ -0,0 +1,6 @@ +C:\Users\Dariusz\documents\visual studio 2013\Projects\Browar\Serwer\bin\Serwer.dll.config +C:\Users\Dariusz\documents\visual studio 2013\Projects\Browar\Serwer\bin\Serwer.dll +C:\Users\Dariusz\documents\visual studio 2013\Projects\Browar\Serwer\bin\Serwer.pdb +C:\Users\Dariusz\documents\visual studio 2013\Projects\Browar\Serwer\obj\Release\Serwer.dll +C:\Users\Dariusz\documents\visual studio 2013\Projects\Browar\Serwer\obj\Release\Serwer.pdb +C:\Users\Dariusz\documents\visual studio 2013\Projects\Browar\Serwer\obj\Release\Serwer.csprojResolveAssemblyReference.cache diff --git a/Browar/Serwer/obj/Release/Serwer.csprojResolveAssemblyReference.cache b/Browar/Serwer/obj/Release/Serwer.csprojResolveAssemblyReference.cache new file mode 100644 index 0000000..54ab7aa Binary files /dev/null and b/Browar/Serwer/obj/Release/Serwer.csprojResolveAssemblyReference.cache differ diff --git a/Browar/Serwer/obj/Release/Serwer.dll b/Browar/Serwer/obj/Release/Serwer.dll new file mode 100644 index 0000000..4ba3763 Binary files /dev/null and b/Browar/Serwer/obj/Release/Serwer.dll differ diff --git a/Browar/Serwer/obj/Release/Serwer.pdb b/Browar/Serwer/obj/Release/Serwer.pdb new file mode 100644 index 0000000..17af09e Binary files /dev/null and b/Browar/Serwer/obj/Release/Serwer.pdb differ diff --git a/Browar/Serwer/obj/Release/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs b/Browar/Serwer/obj/Release/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs new file mode 100644 index 0000000..e69de29 diff --git a/Browar/Serwer/obj/Release/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs b/Browar/Serwer/obj/Release/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs new file mode 100644 index 0000000..e69de29 diff --git a/Browar/Serwer/obj/Release/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs b/Browar/Serwer/obj/Release/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs new file mode 100644 index 0000000..e69de29 diff --git a/Browar/Serwer/obj/Release/TransformWebConfig/assist/Web.config b/Browar/Serwer/obj/Release/TransformWebConfig/assist/Web.config new file mode 100644 index 0000000..c358444 --- /dev/null +++ b/Browar/Serwer/obj/Release/TransformWebConfig/assist/Web.config @@ -0,0 +1,31 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Browar/Serwer/obj/Release/TransformWebConfig/original/Web.config b/Browar/Serwer/obj/Release/TransformWebConfig/original/Web.config new file mode 100644 index 0000000..bfb640d --- /dev/null +++ b/Browar/Serwer/obj/Release/TransformWebConfig/original/Web.config @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/Browar/Serwer/obj/Release/TransformWebConfig/transformed/Web.config b/Browar/Serwer/obj/Release/TransformWebConfig/transformed/Web.config new file mode 100644 index 0000000..4aaef7c --- /dev/null +++ b/Browar/Serwer/obj/Release/TransformWebConfig/transformed/Web.config @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/Browar/Serwer/obj/Release/_WPPLastBuildInfo.txt b/Browar/Serwer/obj/Release/_WPPLastBuildInfo.txt new file mode 100644 index 0000000..a9bf37a Binary files /dev/null and b/Browar/Serwer/obj/Release/_WPPLastBuildInfo.txt differ