コード例 #1
0
        public async Task <IHttpActionResult> PutMitchellClaimType(int id, MitchellClaimType mitchellClaimType)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != mitchellClaimType.MitchellClaimTypeId)
            {
                return(BadRequest());
            }

            db.Entry(mitchellClaimType).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MitchellClaimTypeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #2
0
        public async Task<IHttpActionResult> PutMitchellClaimType(int id, MitchellClaimType mitchellClaimType)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != mitchellClaimType.MitchellClaimTypeId)
            {
                return BadRequest();
            }

            db.Entry(mitchellClaimType).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MitchellClaimTypeExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
コード例 #3
0
        static async Task RunAsync()
        {
            try
            {
                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri(s_wepApiServer);
                    client.DefaultRequestHeaders.Accept.Clear();
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                    MitchellClaimType   claim = null;
                    HttpResponseMessage response;

                    // Get all Claims
                    List <MitchellClaimType> claims        = Claims(client).Result;
                    XmlSerializer            xmlSerializer = new XmlSerializer(typeof(MitchellClaimType));
                    string[] files = Directory.GetFiles("../../NewClaims", "*.xml");

                    // Add New Claims
                    foreach (string fileName in files)
                    {
                        using (StreamReader reader = new StreamReader(fileName))
                        {
                            claim    = (MitchellClaimType)xmlSerializer.Deserialize(reader);
                            response = await client.PostAsJsonAsync <MitchellClaimType>(autoClaimApi, claim).ContinueWith((postTask) => postTask.Result.EnsureSuccessStatusCode());
                        }
                    }
                    claims = Claims(client).Result;
                    claim  = Claim(client, claims.First().MitchellClaimTypeId).Result;

                    // Update Claims
                    files = Directory.GetFiles("../../ClaimUpdates", "*.xml");
                    foreach (string fileName in files)
                    {
                        using (StreamReader reader = new StreamReader(fileName))
                        {
                            MitchellClaimType claimUpdates = (MitchellClaimType)xmlSerializer.Deserialize(reader);
                            claim = (from c in claims where c.ClaimNumber == claimUpdates.ClaimNumber select c).FirstOrDefault();
                            if (claimUpdates.MitchellClaimTypeId != claim.MitchellClaimTypeId)
                            {
                                claimUpdates.MitchellClaimTypeId = claim.MitchellClaimTypeId;
                            }
                            // more to do response = await client.PutAsJsonAsync<MitchellClaimType>(autoClaimApi + "/" + claim.MitchellClaimTypeId, claimUpdates).ContinueWith((postTask) => postTask.Result.EnsureSuccessStatusCode());
                        }
                    }

                    // Read a Claim
                    claim = Claim(client, claim.MitchellClaimTypeId).Result;

                    // Delete a claim
                    // more to do response = await client.DeleteAsync(autoClaimApi + "/" + claim.MitchellClaimTypeId).ContinueWith((postTask) => postTask.Result.EnsureSuccessStatusCode());

                    claim = Claim(client, claim.MitchellClaimTypeId).Result;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
コード例 #4
0
        async public Task <IHttpActionResult> Put(MitchellClaimType claim)
        {
            if (string.IsNullOrEmpty(claim.ClaimNumber))
            {
                return(BadRequest("ClaimNumber is required."));
            }

            return(Ok(await _claimsService.UpdateClaim(claim)));
        }
コード例 #5
0
        public async Task <IHttpActionResult> GetMitchellClaimType(int id)
        {
            MitchellClaimType mitchellClaimType = await db.Claims.FindAsync(id);

            if (mitchellClaimType == null)
            {
                return(NotFound());
            }

            return(Ok(mitchellClaimType));
        }
コード例 #6
0
        public async Task <IHttpActionResult> PostMitchellClaimType(MitchellClaimType mitchellClaimType)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Claims.Add(mitchellClaimType);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = mitchellClaimType.MitchellClaimTypeId }, mitchellClaimType));
        }
コード例 #7
0
        public async Task<IHttpActionResult> PostMitchellClaimType(MitchellClaimType mitchellClaimType)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.Claims.Add(mitchellClaimType);
            await db.SaveChangesAsync();

            return CreatedAtRoute("DefaultApi", new { id = mitchellClaimType.MitchellClaimTypeId }, mitchellClaimType);
        }
コード例 #8
0
        async public Task <IHttpActionResult> Post(MitchellClaimType claim)
        {
            if (string.IsNullOrEmpty(claim.ClaimNumber))
            {
                return(BadRequest("ClaimNumber is required"));
            }

            if (claim.Vehicles == null)
            {
                return(BadRequest("Vehicle Details not availble in input request"));
            }

            return(Ok(await _claimsService.CreateClaim(claim)));
        }
コード例 #9
0
        public async Task <IHttpActionResult> DeleteMitchellClaimType(int id)
        {
            MitchellClaimType mitchellClaimType = await db.Claims.FindAsync(id);

            if (mitchellClaimType == null)
            {
                return(NotFound());
            }

            db.Claims.Remove(mitchellClaimType);
            await db.SaveChangesAsync();

            return(Ok(mitchellClaimType));
        }
コード例 #10
0
ファイル: AutoClaim.cs プロジェクト: timotrob/VelocityDB
        static void ProcessClaimsUsingEntityFramework()
        {
            try
            {
                object dataDir = AppDomain.CurrentDomain.GetData("DataDirectory");
                if (dataDir == null)
                {
                    AppDomain.CurrentDomain.SetData("DataDirectory", Directory.GetCurrentDirectory());
                }
                AutoClaimSQL      sql           = new AutoClaimSQL();
                XmlSerializer     xmlSerializer = new XmlSerializer(typeof(MitchellClaimType));
                MitchellClaimType claim         = new MitchellClaimType();
                string[]          files         = Directory.GetFiles("../../NewClaims", "*.xml");
                foreach (string fileName in files)
                {
                    using (StreamReader reader = new StreamReader(fileName))
                    {
                        claim = (MitchellClaimType)xmlSerializer.Deserialize(reader);
                        sql.NewClaim(claim);
                    }
                }
                claim = sql.ReadClaim(claim.ClaimNumber);
                files = Directory.GetFiles("../../ClaimUpdates", "*.xml");
                foreach (string fileName in files)
                {
                    using (StreamReader reader = new StreamReader(fileName))
                    {
                        MitchellClaimType claimUpdates = (MitchellClaimType)xmlSerializer.Deserialize(reader);
                        sql.UpdateClaim(claimUpdates);
                    }
                }
                claim = sql.ReadClaim(claim.ClaimNumber);

                foreach (var c in sql.FindClaims(claim.LossDate, DateTime.UtcNow))
                {
                    Console.WriteLine(c);
                }
                foreach (var c in sql.FindClaims(claim.LossDate + TimeSpan.FromDays(1), DateTime.UtcNow))
                {
                    Console.WriteLine(c); // should not get here
                }
                sql.DeleteClaim(claim.ClaimNumber);
                claim = sql.ReadClaim(claim.ClaimNumber);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
コード例 #11
0
        //[TestMethod]
        async public Task UpdateClaim()
        {
            var claim = new MitchellClaimType();

            claim.ClaimNumber       = "22c9c23bac142856018ce14a26b6c2991";
            claim.ClaimantFirstName = "George Anil";
            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;

            var result = await controller.Put(claim);

            Assert.AreEqual("Success", result);
        }
コード例 #12
0
        //[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);
        }
コード例 #13
0
        //[TestMethod]
        async public Task CreateClaimWithOutVehicleInfo()
        {
            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;
            var result = await controller.Post(claim);

            BadRequestErrorMessageResult badRequestResult = result as BadRequestErrorMessageResult;

            Assert.AreEqual("Vehicle Details not availble in input request", badRequestResult.Message);
        }
コード例 #14
0
        //[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);
        }
コード例 #15
0
ファイル: Service.cs プロジェクト: nguy2261/codingChallenge
    //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++;
    }
コード例 #16
0
 async public Task <string> AddAsync(MitchellClaimType item)
 {
     return(await CreateClaim(item));
 }
コード例 #17
0
 async public Task <string> UpdateAsync(MitchellClaimType item)
 {
     return(await UpdateClaim(item));
 }
コード例 #18
0
        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());
        }
コード例 #19
0
        async private Task <string> CreateClaim(MitchellClaimType claim)
        {
            string operationStatus = "Failure";

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
                {
                    using (var conn = new SqlConnection(ConnectionString))
                    {
                        conn.Open();
                        DynamicParameters claimParams = new DynamicParameters();
                        claimParams.Add("@ClaimNumber", claim.ClaimNumber);
                        claimParams.Add("@ClaimantFirstName", claim.ClaimantFirstName);
                        claimParams.Add("@ClaimantLastName", claim.ClaimantLastName);
                        claimParams.Add("@StatusKey", claim.Status == StatusCode.OPEN ? 1 : 2);
                        claimParams.Add("@LossDate", claim.LossDate);
                        claimParams.Add("@AssignedAdjusterID", claim.AssignedAdjusterID);

                        await conn.ExecuteAsync(Commands.InsertClaim, claimParams);

                        DynamicParameters LossInfoParams = new DynamicParameters();
                        LossInfoParams.Add("@LossDescription", claim.LossInfo.LossDescription);
                        LossInfoParams.Add("@ReportDate", claim.LossInfo.ReportedDate);
                        LossInfoParams.Add("@ClaimNumber", claim.ClaimNumber);
                        int causeOfLoss = 1;

                        if (claim.LossInfo.CauseOfLoss == CauseOfLossCode.Explosion)
                        {
                            causeOfLoss = 2;
                        }
                        if (claim.LossInfo.CauseOfLoss == CauseOfLossCode.Fire)
                        {
                            causeOfLoss = 3;
                        }
                        if (claim.LossInfo.CauseOfLoss == CauseOfLossCode.Hail)
                        {
                            causeOfLoss = 4;
                        }
                        if (claim.LossInfo.CauseOfLoss == CauseOfLossCode.MechanicalBreakdown)
                        {
                            causeOfLoss = 5;
                        }
                        if (claim.LossInfo.CauseOfLoss == CauseOfLossCode.Other)
                        {
                            causeOfLoss = 6;
                        }

                        LossInfoParams.Add("@CauseOfLossKey", causeOfLoss);

                        await conn.ExecuteAsync(Commands.InsertLossInfoType, LossInfoParams);

                        await conn.ExecuteAsync(Commands.UpdateLossInfoKey, claimParams);

                        foreach (VehicleInfoType v in claim.Vehicles)
                        {
                            DynamicParameters vehicleParams = new DynamicParameters();
                            vehicleParams.Add("@ClaimNumber", claim.ClaimNumber);
                            vehicleParams.Add("@ModelYear", v.ModelYear);
                            vehicleParams.Add("@ModelDescription", v.ModelDescription);
                            vehicleParams.Add("@MakeDescription", v.MakeDescription);
                            vehicleParams.Add("@EngineDescription", v.EngineDescription);
                            vehicleParams.Add("@ExteriorColor", v.ExteriorColor);
                            vehicleParams.Add("@Vin", v.Vin);
                            vehicleParams.Add("@LicPlate", v.LicPlate);
                            vehicleParams.Add("@LicPlateState", v.LicPlateState);
                            vehicleParams.Add("@DamageDescription", v.DamageDescription);
                            vehicleParams.Add("@LicPlateExpDate", v.LicPlateExpDate);
                            vehicleParams.Add("@Mileage", v.Mileage);

                            await conn.ExecuteAsync(Commands.InsertVehicleDamageInfo, vehicleParams);
                        }
                    }
                    scope.Complete();
                    operationStatus = "Success";
                }
            }
            catch (Exception ex)
            {
                operationStatus = ex.Message;
            }
            return(operationStatus);
        }
コード例 #20
0
    // Make a change to alllow hashsets to be used. Overide the equals and gethashcode methods to avoid duplicates
    public override bool Equals(object obj)
    {
        MitchellClaimType q = obj as MitchellClaimType;

        return(q != null && q.ClaimNumber.Equals(this.ClaimNumber));
    }
コード例 #21
0
 async public Task <string> UpdateClaim(MitchellClaimType claim)
 {
     return(await _claimsRepository.UpdateAsync(claim));
 }
コード例 #22
0
ファイル: Service.cs プロジェクト: nguy2261/codingChallenge
 public string returnFromXML(MitchellClaimType searchClaim)
 {
     //This function will convert an MitchellClaimType object into an XML file.
     //This can be done better if I can figure out how I can indent and give space between each element from the XML
     XmlSerializer serializer = new XmlSerializer(typeof(MitchellClaimType));
     StringWriter sw = new StringWriter();
     XmlTextWriter tw = new XmlTextWriter(sw);
     serializer.Serialize(tw, searchClaim);
     return sw.ToString();
 }
コード例 #23
0
        async private Task <string> UpdateClaim(MitchellClaimType claim)
        {
            string operationStatus = "Failure";

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
                {
                    using (var conn = new SqlConnection(ConnectionString))
                    {
                        conn.Open();
                        DynamicParameters claimParams = new DynamicParameters();
                        claimParams.Add("@ClaimNumber", claim.ClaimNumber);
                        IEnumerable <MitchellClaimType> claimFound = await conn.QueryAsync <MitchellClaimType>(string.Format(Commands.GetClaimByClaimNumber, claim.ClaimNumber));

                        if (claimFound.Count <MitchellClaimType>() == 0)
                        {
                            return("Claim does not found.");
                        }

                        claimParams.Add("@ClaimantFirstName", claim.ClaimantFirstName);
                        claimParams.Add("@ClaimantLastName", claim.ClaimantLastName);
                        claimParams.Add("@StatusKey", claim.Status == StatusCode.OPEN ? 1 : 2);
                        claimParams.Add("@LossDate", claim.LossDate);
                        claimParams.Add("@AssignedAdjusterID", claim.AssignedAdjusterID);

                        await conn.ExecuteAsync(Commands.UpdateClaim, claimParams);

                        DynamicParameters LossInfoParams = new DynamicParameters();
                        LossInfoParams.Add("@LossDescription", claim.LossInfo.LossDescription);
                        LossInfoParams.Add("@ReportDate", claim.LossInfo.ReportedDate);
                        LossInfoParams.Add("@ClaimNumber", claim.ClaimNumber);
                        int causeOfLoss = 1;

                        if (claim.LossInfo.CauseOfLoss == CauseOfLossCode.Explosion)
                        {
                            causeOfLoss = 2;
                        }
                        if (claim.LossInfo.CauseOfLoss == CauseOfLossCode.Fire)
                        {
                            causeOfLoss = 3;
                        }
                        if (claim.LossInfo.CauseOfLoss == CauseOfLossCode.Hail)
                        {
                            causeOfLoss = 4;
                        }
                        if (claim.LossInfo.CauseOfLoss == CauseOfLossCode.MechanicalBreakdown)
                        {
                            causeOfLoss = 5;
                        }
                        if (claim.LossInfo.CauseOfLoss == CauseOfLossCode.Other)
                        {
                            causeOfLoss = 6;
                        }

                        LossInfoParams.Add("@CauseOfLossKey", causeOfLoss);

                        await conn.ExecuteAsync(Commands.UpdateLossInfo, LossInfoParams);

                        if (claim.Vehicles != null)
                        {
                            foreach (VehicleInfoType v in claim.Vehicles)
                            {
                                DynamicParameters vehicleParams = new DynamicParameters();
                                vehicleParams.Add("@ClaimNumber", claim.ClaimNumber);
                                // assumed update claim does not have a new vehicle.
                                IEnumerable <MitchellClaimType> claimByVin = await conn.QueryAsync <MitchellClaimType>(string.Format(Commands.GetVehicleDetailsByClaimVin, claim.ClaimNumber, v.Vin));

                                if (claimFound.Count <MitchellClaimType>() == 0)
                                {
                                    scope.Dispose();
                                    return("No vehicle exists with this Vin:" + v.Vin);
                                }

                                vehicleParams.Add("@ModelYear", v.ModelYear);
                                vehicleParams.Add("@MakeDescription", v.MakeDescription);
                                vehicleParams.Add("@EngineDescription", v.EngineDescription);
                                vehicleParams.Add("@ExteriorColor", v.ExteriorColor);
                                vehicleParams.Add("@Vin", v.Vin);
                                vehicleParams.Add("@LicPlate", v.LicPlate);
                                vehicleParams.Add("@LicPlateState", v.LicPlateState);
                                vehicleParams.Add("@DamageDescription", v.DamageDescription);
                                vehicleParams.Add("@LicPlateExpDate", v.LicPlateExpDate);
                                vehicleParams.Add("@Mileage", v.Mileage);

                                await conn.ExecuteAsync(Commands.UpdateVehicleInfo, vehicleParams);
                            }
                        }
                    }
                    scope.Complete();
                }
                operationStatus = "Success";
            }
            catch (Exception ex)
            {
                operationStatus = ex.Message;
            }
            return(operationStatus);
        }