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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .vs/SimpleOrderSearch/v15/.suo
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1,035 changes: 1,035 additions & 0 deletions .vs/config/applicationhost.config

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions SimpleOrderConsoleApp/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.7.0" newVersion="5.2.7.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
255 changes: 255 additions & 0 deletions SimpleOrderConsoleApp/App_Start/SwaggerConfig.cs

Large diffs are not rendered by default.

58 changes: 58 additions & 0 deletions SimpleOrderConsoleApp/Home.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SimpleOrderConsoleApp
{
class Home
{
static void Main(string[] args)
{
Home pro = new Home();

while (true)
{
pro.Choice();
Console.WriteLine("Do you want to continue?(yes/no)");
string ans = Console.ReadLine().ToLower().Trim();
if (ans != "yes")
break;
}

}
public void Choice()
{
OrderSearch objProduct = new OrderSearch();
Console.WriteLine("\n********** Welcome to Sample Order Search **********\n");
Console.WriteLine("Please select option\n1. List all orders\n2. Search order by criteria (Format: Order Number || (MSA && Status)) && CompletionDte)\n3. Exit");
try
{
int i = Convert.ToInt32(Console.ReadLine());

switch (i)
{
case 1:
objProduct.AllRecords();
break;
case 2:
objProduct.Record();
break;
case 3:
Environment.Exit(0);
break;
default:
Console.WriteLine("Invalid option");
break;
}
}
catch (Exception)
{
Console.WriteLine("Invalid option");
}
}


}
}
152 changes: 152 additions & 0 deletions SimpleOrderConsoleApp/OrderSearch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using SimpleOrderWebApi.Models;

namespace SimpleOrderConsoleApp
{
public class OrderSearch
{
HttpClient webClient = new HttpClient();
string apiUrl;
int Count = 0;
public void Record()
{
int intOrderId = 0;
int intMSA = 0;
int intStatus = 0;
//int intOffset = 0;
//int intLimit = 0;
DateTime Date;

OrderNumber:
Console.WriteLine("Please enter the order number\n(If you don't need order number as search,please press 'Enter')");
string strOrderId = Console.ReadLine().Trim();
if (!int.TryParse(strOrderId, out intOrderId) && strOrderId != "")
{
Console.WriteLine("Invalid order number");
goto OrderNumber;
}
if (intOrderId == 0)
{

MSA:
Console.WriteLine("Please enter the MSA number");
string strMSA = Console.ReadLine().Trim();
if (!int.TryParse(strMSA, out intMSA))
{
Console.WriteLine("Please enter a vaild MSA number");
goto MSA;
}
if (intMSA != 0)
{
Status:
Console.WriteLine("Please enter the status number");
string strStatus = Console.ReadLine().Trim();
if (!int.TryParse(strStatus, out intStatus))
{
Console.WriteLine("Please enter a vaild status number");
goto Status;
}
}
}

Datetime:
Console.WriteLine("Please enter the confirmation date and time {MM/DD/YYY HH:MM:SS AM/PM} (Mandatory*)");
string strDate = Console.ReadLine();
if (!DateTime.TryParse(strDate, out Date))
{
Console.WriteLine("Please enter a valid datetime");
goto Datetime;
}

var settings = new JsonSerializerSettings { DateFormatString = "yyyy-MM-ddTHH:mm:ss" };
var jsonDate = JsonConvert.SerializeObject(Date, settings);

string NewDate = jsonDate.Remove(0, 1);
NewDate = NewDate.Remove(19, 1);

var input = new
{
OrderId = intOrderId,
MSA = intMSA,
Status = intStatus,
Date = NewDate,
Limit = 3,
Offset = 0

};

string parameter = "?obj.status=" + input.Status + "&obj.MSA=" + input.MSA + "&obj.OrderID=" + input.OrderId + "&obj.CompletionDte=" + NewDate + "&obj.Limit=" + input.Limit;
apiUrl = "http://localhost:54861/api/Order/Search" + parameter;

GetRecord();
int intoffset = 0;

if (Count >= input.Limit)
{
do
{
Console.WriteLine("Please enter 'Next' to go for next page");
if (Console.ReadLine().ToLower().Trim() == "next")
{
intoffset = intoffset + 3;
parameter = "?obj.status=" + input.Status + "&obj.MSA=" + input.MSA + "&obj.OrderID=" + input.OrderId + "&obj.CompletionDte=" + NewDate + "&obj.Limit=" + input.Limit + "&obj.Offset=" + intoffset;
apiUrl = "http://localhost:54861/api/Order/Search" + parameter;
GetRecord();
}
else
{
break;
}
}
while ((intoffset) >= Count);
}

}

public void AllRecords()
{
apiUrl = "http://localhost:54861/api/Order";
GetRecord();
}
public void GetRecord()
{
IEnumerable<Order> OrderModel;
List<Order> liOrder = new List<Order>();

HttpResponseMessage webResponse = webClient.GetAsync(apiUrl).Result;
OrderModel = webResponse.Content.ReadAsAsync<IEnumerable<Order>>().Result;

if (webResponse.IsSuccessStatusCode)
{
if (OrderModel != null && OrderModel.GetEnumerator().MoveNext())
{
Console.WriteLine("\n*********************Odrers********************\n\n");
foreach (Order item in OrderModel)
{

Console.WriteLine("OrderId: {0}\nCode:{1}\nShipperID:{2}\nDriverID:{3}\nCompletionDte:{4}\nStatus:{5}\nMSA:{6}\nDuration:{7}\nOfferType:{8}\n",
item.OrderID, item.Code, item.ShipperID, item.DriverID, item.CompletionDte, item.Status, item.MSA, item.Duration, item.OfferType);
Count = Convert.ToInt32(item.PageSize);
}

}
else
{
Console.WriteLine("No data");
}
}

else
{
Console.WriteLine("Error");
}
Console.ReadLine();
}
}
}
36 changes: 36 additions & 0 deletions SimpleOrderConsoleApp/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
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("SimpleOrderConsoleApp")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SimpleOrderConsoleApp")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[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("90159a69-e57a-4159-9249-977bd6cf6114")]

// 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 Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
83 changes: 83 additions & 0 deletions SimpleOrderConsoleApp/SimpleOrderConsoleApp.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{90159A69-E57A-4159-9249-977BD6CF6114}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>SimpleOrderConsoleApp</RootNamespace>
<AssemblyName>SimpleOrderConsoleApp</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Swashbuckle.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cd1bb07a5ac7c7bc, processorArchitecture=MSIL">
<HintPath>..\packages\Swashbuckle.Core.5.6.0\lib\net40\Swashbuckle.Core.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Net.Http.Formatting, Version=5.2.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.WebApi.Client.5.2.7\lib\net45\System.Net.Http.Formatting.dll</HintPath>
</Reference>
<Reference Include="System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.WebApi.Core.4.0.30506.0\lib\net40\System.Web.Http.dll</HintPath>
</Reference>
<Reference Include="System.Web.Http.WebHost, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.WebApi.WebHost.4.0.20710.0\lib\net40\System.Web.Http.WebHost.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="WebActivatorEx, Version=2.0.0.0, Culture=neutral, PublicKeyToken=7b26dc2a43f6a0d4, processorArchitecture=MSIL">
<HintPath>..\packages\WebActivatorEx.2.0\lib\net40\WebActivatorEx.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="App_Start\SwaggerConfig.cs" />
<Compile Include="Home.cs" />
<Compile Include="OrderSearch.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SimpleOrderWebApi\SimpleOrderWebApi.csproj">
<Project>{db5a086c-9121-4c74-a641-29a41505a86e}</Project>
<Name>SimpleOrderWebApi</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
Binary file not shown.
Binary file not shown.
Loading