/// <summary>
 /// Method to Serialize data(from model data to xml)
 /// </summary>
 /// <param name="mitchellClaim">model data</param>
 /// <returns>string contains xml type</returns>
 private static string GETMitchellClaimXML(MitchellClaims mitchellClaim)
 {
     MemoryStream stream = null;
     TextWriter writer = null;
     try
     {
         stream = new MemoryStream(); // read xml in memory
         writer = new StreamWriter(stream, Encoding.Unicode);
         // get serialise object
         XmlSerializer serializer = new XmlSerializer(typeof(MitchellClaims));
         serializer.Serialize(writer, mitchellClaim); // read object
         int count = (int)stream.Length; // saves object in memory stream
         byte[] arr = new byte[count];
         stream.Seek(0, SeekOrigin.Begin);
         // copy stream contents in byte array
         stream.Read(arr, 0, count);
         UnicodeEncoding utf = new UnicodeEncoding(); // convert byte array to string
         return utf.GetString(arr).Trim();
     }
     catch
     {
         return string.Empty;
     }
     finally
     {
         if (stream != null) stream.Close();
         if (writer != null) writer.Close();
     }
 }
 /// <summary>
 /// Method to write xml file
 /// </summary>
 /// <param name="mitchellClaims">mitchellCliams data</param>
 /// <param name="backStorePath">backstore path</param>
 private static void WriteXMLBackStore(MitchellClaims mitchellClaims, string backStorePath)
 {
     string mitchellClaimXML = GETMitchellClaimXML(mitchellClaims);
     if(File.Exists(backStorePath))
         File.Delete(backStorePath);
     File.WriteAllText(backStorePath, mitchellClaimXML);
 }
        /// <summary>
        /// Method to create a new claim
        /// </summary>
        /// <param name="createXMLPath">create claim xml file path</param>
        /// <param name="BackStoreXMLPath">back store xml file path</param>
        private static void CreateMitchellClaim(string createXMLPath, string backStoreXMLPath)
        {
            MitchellClaims backStoreXML = new MitchellClaims();
            if(File.Exists(backStoreXMLPath))
                backStoreXML = GetMitchellClaimObject(backStoreXMLPath);

            MitchellClaims createXML = GetMitchellClaimObject(createXMLPath);

            MitchellClaims consolidatedBackStore = ConsolidateBackStore(backStoreXML, createXML);

            WriteXMLBackStore(consolidatedBackStore, backStoreXMLPath);

        }
 /// <summary>
 /// Method to consolidate backstore data and record to be created
 /// </summary>
 /// <param name="backStoreXML">backstore data</param>
 /// <param name="createXML">create data</param>
 /// <returns>Consolidated data</returns>
 private static MitchellClaims ConsolidateBackStore(MitchellClaims backStoreXML, MitchellClaims createXML)
 {
     MitchellClaims mitchellClaims = new MitchellClaims();
     mitchellClaims.MitchellClaim.AddRange(backStoreXML.MitchellClaim);
     mitchellClaims.MitchellClaim.AddRange(createXML.MitchellClaim);
     return mitchellClaims;
 }
        /// <summary>
        /// Method to delete a claim
        /// </summary>
        /// <param name="claimNumber">Claim number</param>
        /// <param name="backStoreXMLPath">back store xml file path</param>
        /// <returns>delete success or fail</returns>
        private static bool DeleteMitchellClaims(string claimNumber, string backStoreXMLPath)
        {
            MitchellClaims backStoreXML = new MitchellClaims();
            if (File.Exists(backStoreXMLPath))
                backStoreXML = GetMitchellClaimObject(backStoreXMLPath);

            MitchellClaim mitchellClaimToBeDeleted = backStoreXML.MitchellClaim.Find(x=>x.ClaimNumber == claimNumber);

            if (mitchellClaimToBeDeleted != null)
            {
                backStoreXML.MitchellClaim.Remove(mitchellClaimToBeDeleted);
                WriteXMLBackStore(backStoreXML, backStoreXMLPath);
                return true;
            }

            return false;

        }