Skip to content

Commit

Permalink
Merge pull request #14 from MahdiyarGHD/develop
Browse files Browse the repository at this point in the history
Some fixes
  • Loading branch information
Ali-YousefiTelori authored Sep 2, 2023
2 parents 6ad7391 + cbd1d13 commit 42f4fc7
Show file tree
Hide file tree
Showing 12 changed files with 441 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,84 @@ public string BaseUrl
partial void PrepareRequest(System.Net.Http.HttpClient client, System.Net.Http.HttpRequestMessage request, System.Text.StringBuilder urlBuilder);
partial void ProcessResponse(System.Net.Http.HttpClient client, System.Net.Http.HttpResponseMessage response);

/// <returns>Success</returns>
/// <exception cref="ApiException">A server side error occurred.</exception>
public virtual System.Threading.Tasks.Task<MessageContract> IsKeyExistsAsync(IsKeyExistRequestContract body)
{
return IsKeyExistsAsync(body, System.Threading.CancellationToken.None);
}

/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
/// <returns>Success</returns>
/// <exception cref="ApiException">A server side error occurred.</exception>
public virtual async System.Threading.Tasks.Task<MessageContract> IsKeyExistsAsync(IsKeyExistRequestContract body, System.Threading.CancellationToken cancellationToken)
{
var urlBuilder_ = new System.Text.StringBuilder();
urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/api/Category/IsKeyExists");

var client_ = _httpClient;
var disposeClient_ = false;
try
{
using (var request_ = new System.Net.Http.HttpRequestMessage())
{
var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(body, _settings.Value);
var content_ = new System.Net.Http.StringContent(json_);
content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json");
request_.Content = content_;
request_.Method = new System.Net.Http.HttpMethod("POST");
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("text/plain"));

PrepareRequest(client_, request_, urlBuilder_);

var url_ = urlBuilder_.ToString();
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);

PrepareRequest(client_, request_, url_);

var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
var disposeResponse_ = true;
try
{
var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
if (response_.Content != null && response_.Content.Headers != null)
{
foreach (var item_ in response_.Content.Headers)
headers_[item_.Key] = item_.Value;
}

ProcessResponse(client_, response_);

var status_ = (int)response_.StatusCode;
if (status_ == 200)
{
var objectResponse_ = await ReadObjectResponseAsync<MessageContract>(response_, headers_, cancellationToken).ConfigureAwait(false);
if (objectResponse_.Object == null)
{
throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
}
return objectResponse_.Object;
}
else
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
}
}
finally
{
if (disposeResponse_)
response_.Dispose();
}
}
}
finally
{
if (disposeClient_)
client_.Dispose();
}
}

/// <returns>Success</returns>
/// <exception cref="ApiException">A server side error occurred.</exception>
public virtual System.Threading.Tasks.Task<Int64MessageContract> AddAsync(CreateCategoryRequestContract body)
Expand Down Expand Up @@ -4280,6 +4358,36 @@ protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.Cal
}
}

[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.19.0.0 (NJsonSchema v10.9.0.0 (Newtonsoft.Json v13.0.3.0))")]
public partial class IsKeyExistRequestContract : System.ComponentModel.INotifyPropertyChanged
{
private string _key;

[Newtonsoft.Json.JsonProperty("key", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public string Key
{
get { return _key; }

set
{
if (_key != value)
{
_key = value;
RaisePropertyChanged();
}
}
}

public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;

protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null)
{
var handler = PropertyChanged;
if (handler != null)
handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
}
}

[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.19.0.0 (NJsonSchema v10.9.0.0 (Newtonsoft.Json v13.0.3.0))")]
public partial class LanguageContract : System.ComponentModel.INotifyPropertyChanged
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,55 @@
"version": "1.0"
},
"paths": {
"/api/Category/IsKeyExists": {
"post": {
"tags": [
"Category"
],
"operationId": "IsKeyExists",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/IsKeyExistRequestContract"
}
},
"text/json": {
"schema": {
"$ref": "#/components/schemas/IsKeyExistRequestContract"
}
},
"application/*+json": {
"schema": {
"$ref": "#/components/schemas/IsKeyExistRequestContract"
}
}
}
},
"responses": {
"200": {
"description": "Success",
"content": {
"text/plain": {
"schema": {
"$ref": "#/components/schemas/MessageContract"
}
},
"application/json": {
"schema": {
"$ref": "#/components/schemas/MessageContract"
}
},
"text/json": {
"schema": {
"$ref": "#/components/schemas/MessageContract"
}
}
}
}
}
}
},
"/api/Category/Add": {
"post": {
"tags": [
Expand Down Expand Up @@ -1945,6 +1994,16 @@
}
}
},
"IsKeyExistRequestContract": {
"type": "object",
"additionalProperties": false,
"properties": {
"key": {
"type": "string",
"nullable": true
}
}
},
"LanguageContract": {
"type": "object",
"additionalProperties": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Platforms>AnyCPU;x64;x86</Platforms>
<Authors>EasyMicroservices</Authors>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>0.0.0.4</Version>
<Version>0.0.0.5</Version>
<Description>client generated code.</Description>
<Copyright>[email protected]</Copyright>
<PackageTags>microservice,Content,Contents,client</PackageTags>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using EasyMicroservices.ContentsMicroservice.Database.Entities;
using EasyMicroservices.Cores.Relational.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using System;

namespace EasyMicroservices.ContentsMicroservice.Database.Contexts
{
Expand Down Expand Up @@ -44,8 +45,24 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
.WithMany(x => x.Contents)
.HasForeignKey(x => x.LanguageId);
});

modelBuilder.Entity<LanguageEntity>(model =>
{
model.HasData(
new LanguageEntity()
{
Id = 1,
Name = "fa-IR",
CreationDateTime = DateTime.Now
},
new LanguageEntity()
{
Id = 2,
Name = "en-US",
CreationDateTime = DateTime.Now
}
);
model.HasKey(x => x.Id);
model.HasIndex(x => x.Name).IsUnique();
});
Expand Down
Loading

0 comments on commit 42f4fc7

Please sign in to comment.