//[TestMethod] public async Task CreateClaim() { var claim = new MitchellClaimType(); claim.ClaimNumber = "22c9c23bac142856018ce14a26b6c2991"; claim.ClaimantFirstName = "George"; claim.ClaimantLastName = "Washington"; claim.Status = StatusCode.OPEN; claim.LossDate = Convert.ToDateTime("2014-07-09T17:19:13.631-07:00"); claim.LossInfo = new LossInfoType() { CauseOfLoss = CauseOfLossCode.Collision, ReportedDate = Convert.ToDateTime("2014-07-10T17:19:13.676-07:00"), LossDescription = "Crashed into an apple tree" }; claim.AssignedAdjusterID = 23424; VehicleInfoType[] vehiclesInfo = new VehicleInfoType[1]; vehiclesInfo[0] = new VehicleInfoType() { Vin = "1M8GDM9AXKP042788", ModelYear = 2015, MakeDescription = "Ford", ModelDescription = "Mustang", EngineDescription = "EcoBoost", ExteriorColor = "Deep Impact Blue", LicPlate = "NO1PRES", LicPlateState = "VA", LicPlateExpDate = Convert.ToDateTime("2015-03-10-07:00"), DamageDescription = "Front end smashed in. Apple dents in roof.", Mileage = 1776 }; claim.Vehicles = vehiclesInfo; var result = await controller.Post(claim); OkNegotiatedContentResult <string> conNegResult = result as OkNegotiatedContentResult <string>; Assert.AreEqual("Success", conNegResult.Content); }
//[TestMethod] async public Task CreateClaimWithOutClaimNumber() { var claim = new MitchellClaimType(); claim.ClaimantFirstName = "George"; claim.ClaimantLastName = "Washington"; claim.Status = StatusCode.OPEN; claim.LossDate = Convert.ToDateTime("2014-07-09T17:19:13.631-07:00"); claim.LossInfo = new LossInfoType() { CauseOfLoss = CauseOfLossCode.Collision, ReportedDate = Convert.ToDateTime("2014-07-10T17:19:13.676-07:00"), LossDescription = "Crashed into an apple tree" }; claim.AssignedAdjusterID = 23424; VehicleInfoType[] vehiclesInfo = new VehicleInfoType[1]; vehiclesInfo[0] = new VehicleInfoType() { Vin = "1M8GDM9AXKP042788", ModelYear = 2015, MakeDescription = "Ford", ModelDescription = "Mustang", EngineDescription = "EcoBoost", ExteriorColor = "Deep Impact Blue", LicPlate = "NO1PRES", LicPlateState = "VA", LicPlateExpDate = Convert.ToDateTime("2015-03-10-07:00"), DamageDescription = "Front end smashed in. Apple dents in roof.", Mileage = 1776 }; claim.Vehicles = vehiclesInfo; var result = await controller.Post(claim); BadRequestErrorMessageResult badRequestResult = result as BadRequestErrorMessageResult; Assert.AreEqual("ClaimNumber is required", badRequestResult.Message); }
//Helper Function - Not in web service public void loadfromXML(XmlDocument xdoc) { //Read the information from the xml xdoc XML Document //Assumption: All submitted files must be in this formatting var tClaimNumber = xdoc.DocumentElement.ChildNodes[0].InnerText; var tClaimFirstName = xdoc.DocumentElement.ChildNodes[1].InnerText; var tClaimLastName = xdoc.DocumentElement.ChildNodes[2].InnerText; var tStatus = (StatusCode)Enum.Parse(typeof(StatusCode), xdoc.DocumentElement.ChildNodes[3].InnerText); var tLossDate = DateTime.Parse(xdoc.DocumentElement.ChildNodes[4].InnerText); var aaID = long.Parse(xdoc.DocumentElement.ChildNodes[6].InnerText); var li = xdoc.DocumentElement.ChildNodes[5]; var ColCode = (CauseOfLossCode)Enum.Parse(typeof(CauseOfLossCode), li.ChildNodes[0].InnerText, false); var date = DateTime.Parse(li.ChildNodes[1].InnerText); var des = li.ChildNodes[2].InnerText; var tLossInfo = new LossInfoType(ColCode, date, des); var vehi = xdoc.DocumentElement.ChildNodes[7]; //Reading Vehicles attributes of the claim xml file VehicleListType VehicleList = new VehicleListType(); foreach (XmlNode veNode in vehi) { var ModelYear = int.Parse(veNode.ChildNodes.Item(1).InnerText); var MakeDescription = veNode.ChildNodes.Item(2).InnerText; var ModelDescription = veNode.ChildNodes.Item(3).InnerText; var EngineDescription = veNode.ChildNodes.Item(4).InnerText; var ExteriorColor = veNode.ChildNodes.Item(5).InnerText; var Vin = veNode.ChildNodes.Item(0).InnerText; var LicPlate = veNode.ChildNodes.Item(6).InnerText; var LicPlateState = veNode.ChildNodes.Item(7).InnerText; var LicPlateExpDate = DateTime.Parse(veNode.ChildNodes.Item(8).InnerText); var DamageDescription = veNode.ChildNodes.Item(9).InnerText; var Mileage = int.Parse(veNode.ChildNodes.Item(10).InnerText); var tVehicle = new VehicleInfoType(ModelYear, MakeDescription, ModelDescription, EngineDescription, ExteriorColor, Vin, LicPlate, LicPlateState, LicPlateExpDate, DamageDescription, Mileage); VehicleList.add(tVehicle); } //Create an MitchellClaimType object based on the information getting from XML file MitchellClaimType addClaim = new MitchellClaimType(tClaimNumber, tClaimFirstName, tClaimLastName, tStatus, tLossDate, tLossInfo, aaID, VehicleList); //In this demo, this will add the new submitted claim into the database //In real program, this will fetch this object into the database - SQL Server or anything else backing_store[claimCount] = addClaim; claimCount++; }
public VehicleListType(int num) { VehicleInfoType[] VehiclesDetails = new VehicleInfoType[num]; }
public void add(VehicleInfoType vh) { VehiclesDetails[count] = vh; count++; }
async private Task <IEnumerable <MitchellClaimType> > FindClaims(string query = "") { IEnumerable <Claim> oList = null; List <MitchellClaimType> claims = new List <MitchellClaimType>(); try { using (var conn = new SqlConnection(ConnectionString)) { await conn.OpenAsync(); oList = await conn.QueryAsync <Claim>(query == ""?Commands.GetAllClaims : query); if (oList != null && oList.Count <Claim>() > 0) { foreach (var item in oList) { MitchellClaimType claim = new MitchellClaimType(); claim.AssignedAdjusterID = item.AssignedAdjusterID; claim.ClaimantFirstName = item.ClaimantFirstName; claim.ClaimantLastName = item.ClaimantLastName; claim.ClaimNumber = item.ClaimNumber; claim.LossDate = item.LossDate; CauseOfLossCode c = CauseOfLossCode.Collision; if (item.CauseOfLossKey == 2) { c = CauseOfLossCode.Explosion; } if (item.CauseOfLossKey == 3) { c = CauseOfLossCode.Fire; } if (item.CauseOfLossKey == 4) { c = CauseOfLossCode.Hail; } if (item.CauseOfLossKey == 5) { c = CauseOfLossCode.MechanicalBreakdown; } if (item.CauseOfLossKey == 6) { c = CauseOfLossCode.Other; } claim.LossInfo = new LossInfoType { CauseOfLoss = c, LossDescription = item.LossDescription, ReportedDate = item.ReportDate }; claim.Status = item.StatusKey == 1 ? StatusCode.OPEN : StatusCode.CLOSED; IEnumerable <VehicleDamageInfo> vehicleInfo = await conn.QueryAsync <VehicleDamageInfo>(string.Format(Commands.GetVehicleDetailsByClaim, item.ClaimNumber)); if (vehicleInfo != null) { VehicleInfoType[] vInfo = new VehicleInfoType[vehicleInfo.Count <VehicleDamageInfo>()]; int j = 0; foreach (var v in vehicleInfo) { vInfo[j] = new VehicleInfoType() { DamageDescription = v.DamageDescription, EngineDescription = v.EngineDescription, ExteriorColor = v.ExteriorColor, LicPlate = v.LicPlate, LicPlateExpDate = v.LicPlateExpDate, MakeDescription = v.MakeDescription, ModelYear = v.ModelYear, Vin = v.Vin, LicPlateState = v.LicPlateState, ModelDescription = v.ModelDescription }; j++; } claim.Vehicles = vInfo; } claims.Add(claim); } } } } catch { } return(claims.AsEnumerable()); }