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
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
################################################################################
# This .gitignore file was automatically created by Microsoft(R) Visual Studio.
################################################################################

/SimpleOrderSearchConsole/.vs/SimpleOrderSearchConsole/v16
/SimpleOrderSearchConsole/SimpleOrderSearchConsole/bin/Debug
/SimpleOrderSearchConsole/SimpleOrderSearchConsole/obj/Debug
/SearchOrderWebService/.vs/SearchOrderWebService
/SearchOrderWebService/packages
/SearchOrderWebService/SearchOrderWebService/bin
/SearchOrderWebService/SearchOrderWebService/obj/Debug
6 changes: 6 additions & 0 deletions How_to_Run.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# SimpleOrderSearch

1. Pull or download both the projects into your local directory.
2. Open "SearchOrderWebService"(Web Service Project) into Visual Studio and Run it.
3. Open the "SimpleOrderSearchConsole"(Console App) and Run it (Make sure your Service Project is Running and listening in the web browser).
4. Provide your Input "((OrderID || (MSA && Status)) && CompletionDte)" and get the result accordingly.
25 changes: 25 additions & 0 deletions SearchOrderWebService/SearchOrderWebService.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29519.87
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SearchOrderWebService", "SearchOrderWebService\SearchOrderWebService.csproj", "{3FA4CD80-B568-4814-A856-9AB232AC45F4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3FA4CD80-B568-4814-A856-9AB232AC45F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3FA4CD80-B568-4814-A856-9AB232AC45F4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3FA4CD80-B568-4814-A856-9AB232AC45F4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3FA4CD80-B568-4814-A856-9AB232AC45F4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {05BDA542-DCBE-4AB5-B737-4ECB5501D329}
EndGlobalSection
EndGlobal
137 changes: 137 additions & 0 deletions SearchOrderWebService/SearchOrderWebService/Data/OrderInfo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@

[
{
"OrderID": 36,
"ShipperID": 4,
"DriverID": 35,
"CompletionDte": "2018-01-12T05:10:00",
"Status": 10,
"Code": "R4C877FF",
"MSA": 1,
"Duration": "92.00",
"OfferType": 1
},
{
"OrderID": 37,
"ShipperID": 4,
"DriverID": 243,
"CompletionDte": "2018-02-15T05:10:00",
"Status": 10,
"Code": "R47077FF",
"MSA": 1,
"Duration": "43.00",
"OfferType": 1
},
{
"OrderID": 38,
"ShipperID": 4,
"DriverID": 35,
"CompletionDte": "2018-01-31T05:10:00",
"Status": 10,
"Code": "R6453FF",
"MSA": 2,
"Duration": "120.00",
"OfferType": 1
},
{
"OrderID": 39,
"ShipperID": 4,
"DriverID": 35,
"CompletionDte": "2018-01-31T05:10:00",
"Status": 10,
"Code": "R4C877DS",
"MSA": 4,
"Duration": "15.00",
"OfferType": 1
},
{
"OrderID": 40,
"ShipperID": 4,
"DriverID": 35,
"CompletionDte": "2018-01-31T05:10:00",
"Status": 10,
"Code": "R4C9999F",
"MSA": 1,
"Duration": "111.00",
"OfferType": 1
},
{
"OrderID": 41,
"ShipperID": 67,
"DriverID": 35,
"CompletionDte": "2018-01-31T05:10:00",
"Status": 10,
"Code": "R4C87S32",
"MSA": 1,
"Duration": "54.00",
"OfferType": 1
},
{
"OrderID": 42,
"ShipperID": 4,
"DriverID": 35,
"CompletionDte": "2018-01-31T05:10:00",
"Status": 10,
"Code": "R4C87123",
"MSA": 1,
"Duration": "92.00",
"OfferType": 1
},
{
"OrderID": 43,
"ShipperID": 4,
"DriverID": 35,
"CompletionDte": "2018-01-31T05:10:00",
"Status": 10,
"Code": "R42G77FF",
"MSA": 1,
"Duration": "40.00",
"OfferType": 1
},
{
"OrderID": 44,
"ShipperID": 4,
"DriverID": 35,
"CompletionDte": "2018-01-31T05:10:00",
"Status": 10,
"Code": "R4002WFF",
"MSA": 1,
"Duration": "92.00",
"OfferType": 2
},
{
"OrderID": 45,
"ShipperID": 4,
"DriverID": 35,
"CompletionDte": "2018-01-31T05:10:00",
"Status": 20,
"Code": "R400KHFF",
"MSA": 3,
"Duration": "23.00",
"OfferType": 1
},
{
"OrderID": 46,
"ShipperID": 24,
"DriverID": 35,
"CompletionDte": "2018-01-31T05:10:00",
"Status": 61,
"Code": "R4C437FF",
"MSA": 1,
"Duration": "92.00",
"OfferType": 1
},
{
"OrderID": 47,
"ShipperID": 121,
"DriverID": 35,
"CompletionDte": "2018-03-1T05:10:00",
"Status": 10,
"Code": "R422AQF",
"MSA": 1,
"Duration": "66.00",
"OfferType": 2
}

]

31 changes: 31 additions & 0 deletions SearchOrderWebService/SearchOrderWebService/Model/OrderInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Web;

namespace SearchOrderWebService.Model
{
[DataContract]
public class OrderInfo
{
[DataMember]
public int OrderId { get; set; }
[DataMember]
public int ShipperId { get; set; }
[DataMember]
public int DriverId { get; set; }
[DataMember]
public DateTime? CompletionDte { get; set; }
[DataMember]
public int Status { get; set; }
[DataMember]
public string Code { get; set; }
[DataMember]
public int MSA { get; set; }
[DataMember]
public float Duration { get; set; }
[DataMember]
public int OfferType { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Web;

namespace SearchOrderWebService.Model
{
[DataContract]
public class SearchCriteria
{
[DataMember]
public int OrderId { get; set; }
[DataMember]
public int MSA { get; set; }
[DataMember]
public DateTime? CompletionDte { get; set; }
[DataMember]
public int Status { get; set; }

public bool IsValid()
{
bool bValid = false;
if (CompletionDte.HasValue)
{
if (OrderId > 0)
{
bValid = true;
}
else if (MSA > 0 && Status > 0)
{
bValid = true;
}
}


return bValid;
}
}
}
Original file line number Diff line number Diff line change
@@ -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("SearchOrderWebService")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SearchOrderWebService")]
[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("3fa4cd80-b568-4814-a856-9ab232ac45f4")]

// 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")]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%@ WebService Language="C#" CodeBehind="SearchOrderService.asmx.cs" Class="SearchOrderWebService.SearchOrderService" %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using Newtonsoft.Json;
using SearchOrderWebService.Model;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Services;

namespace SearchOrderWebService
{
/// <summary>
/// Summary description for SearchOrderService
/// </summary>
[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 SearchOrderService : System.Web.Services.WebService
{

[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
[WebMethod]
public void TestSearchOrder()
{
var data = SearchOrder(new SearchCriteria { OrderId = 39, CompletionDte = DateTime.Parse("2018-01-31T05:10:00") });
}
[WebMethod]
public List<OrderInfo> SearchOrder(SearchCriteria searchCriteria)
{
var dataToSend = new List<OrderInfo>();
int page = 0;
int pageSize = 20;
if (searchCriteria?.IsValid() ?? false)
{
//var data = GetJsondata();
StreamReader streamReader = new StreamReader(Server.MapPath("~/Data/OrderInfo.json"));
string readData = streamReader.ReadToEnd();
var dataSet = JsonConvert.DeserializeObject<List<OrderInfo>>(readData);
if (dataSet.Count() > 0)
{
var pageData = new List<OrderInfo>();
if (searchCriteria?.CompletionDte != null)
{
if (searchCriteria?.OrderId != null)
{
pageData = dataSet.Where(x => x.OrderId == searchCriteria.OrderId && x.CompletionDte.Value.Date == searchCriteria.CompletionDte.Value.Date)?.ToList();
}
else if (searchCriteria?.MSA != null && searchCriteria?.Status != null)
{
pageData = dataSet.Where(x => x.MSA == searchCriteria.MSA && x.Status == searchCriteria.Status && x.CompletionDte.Value.Date == searchCriteria.CompletionDte.Value.Date)?.ToList();
}
}
if (pageData?.Count() > 0)
{
dataToSend = pageData?.Skip(page * pageSize).Take(pageSize).ToList();
}
}
}
return dataToSend;
}
}
}
Loading