public static OfficersView GetPhotos(string masonicYear, string lodgeName, string xmlFileName)
 {
     OfficersView officersView = new OfficersView();
     officersView.MasonicYear = masonicYear;
     try
     {
         XmlDocument xdoc = new XmlDocument();
         xdoc.Load(xmlFileName);
         XmlNode PictureNode;
         string masonicId;
         XmlNode MasonicYearNode = xdoc.SelectSingleNode("//Officers/Year[@MasonicYear='" + masonicYear + "']");
         if (MasonicYearNode != null)
         {
             string[] chairs = { "WM", "SW", "JW", "SD", "JD", "TR", "SC", "TY", "SS", "JS", "MS", "MR", "CP", };
             string pic;
             foreach (string chair in chairs)
             {
                 pic = "";
                 if (MasonicYearNode.SelectSingleNode(chair) != null)
                 {
                     PictureNode = xdoc.SelectSingleNode("//Officers/Year[@MasonicYear='" + masonicYear + "']/" + chair + "/Picture");
                     if (PictureNode != null)
                     {
                         pic = "/Pictures/" + lodgeName + "/" + PictureNode.InnerText;
                     }
                     else
                     {
                         masonicId = MasonicYearNode.SelectSingleNode(chair).Attributes["MasonId"].InnerText;
                         PictureNode = xdoc.SelectSingleNode("//Members/Member[@MasonId='" + masonicId + "']/Picture");
                         if (PictureNode != null)
                         {
                             pic = "/Pictures/" + lodgeName + "/" + PictureNode.InnerText;
                         }
                     }
                     if (pic != "")
                     {
                         switch (chair)
                         {
                             case "WM": officersView.WM = pic; break;
                             case "SW": officersView.SW = pic; break;
                             case "JW": officersView.JW = pic; break;
                             case "SD": officersView.SD = pic; break;
                             case "JD": officersView.JD = pic; break;
                             case "TR": officersView.TR = pic; break;
                             case "SC": officersView.SC = pic; break;
                             case "TY": officersView.TY = pic; break;
                             case "SS": officersView.SS = pic; break;
                             case "JS": officersView.JS = pic; break;
                             case "MS": officersView.MS = pic; break;
                             case "MR": officersView.MR = pic; break;
                             case "CP": officersView.CP = pic; break;
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex) { officersView.MasonicYear = ex.Message; }
     return officersView;
 }
        public static string AddEditOfficers(OfficersView officers, string xmlFileName)
        {
            string success = "ono";
            try
            {
                XmlDocument xdoc = new XmlDocument();
                xdoc.Load(xmlFileName);
                XmlNode MasonicYearNode = xdoc.SelectSingleNode("//Officers/Year[@MasonicYear='" + officers.MasonicYear + "']");
                XmlAttribute MasonId;
                XmlNode ChairNode;
                if (MasonicYearNode == null)
                {
                    MasonicYearNode = xdoc.CreateElement("Year");
                    XmlAttribute MasonicYearAttr = xdoc.CreateAttribute("MasonicYear");
                    MasonicYearAttr.InnerText = officers.MasonicYear;
                    MasonicYearNode.Attributes.Append(MasonicYearAttr);
                    XmlNode OfficersNode = xdoc.SelectSingleNode("//Officers");
                    OfficersNode.AppendChild(MasonicYearNode);
                    MasonicYearNode = xdoc.SelectSingleNode("//Officers/Year[@MasonicYear='" + officers.MasonicYear + "']");
                }
                string[,] chairs = new string[,] {
                { "WM", officers.WM },
                { "SW", officers.SW },
                { "JW", officers.JW },
                { "SD", officers.SD },
                { "JD", officers.JD },
                { "TR", officers.TR },
                { "SC", officers.SC },
                { "TY", officers.TY },
                { "SS", officers.SS },
                { "JS", officers.JS },
                { "MS", officers.MS },
                { "MR", officers.MR },
                { "CP", officers.CP }, };
                for (int i = 0; i < chairs.GetLength(0); i++)
                {
                    if (chairs[i, 1] != "000")
                    {
                        ChairNode = MasonicYearNode.SelectSingleNode(chairs[i, 0]);
                        if (ChairNode == null)
                        { ChairNode = xdoc.CreateElement(chairs[i, 0]); MasonId = xdoc.CreateAttribute("MasonId"); MasonId.InnerText = chairs[i, 1]; ChairNode.Attributes.Append(MasonId); MasonicYearNode.AppendChild(ChairNode); }
                        else { ChairNode.Attributes["MasonId"].InnerText = chairs[i, 1]; }
                    }
                }

                xdoc.Save(xmlFileName);
                success = "ok";
            }
            catch (Exception ex) { success = ex.Message; }
            return success;
        }
 public static OfficersView GetOfficers(string masonicYear, string xmlFileName)
 {
     OfficersView officersView = new OfficersView();
     try
     {
         XmlDocument xdoc = new XmlDocument();
         xdoc.Load(xmlFileName);
         XmlNode MasonicYearNode = xdoc.SelectSingleNode("//Officers/Year[@MasonicYear='" + masonicYear + "']");
         if (MasonicYearNode != null)
         {
             if (MasonicYearNode.SelectSingleNode("WM") != null)
                 officersView.WM = MasonicYearNode["WM"].Attributes[0].InnerText;
             if (MasonicYearNode.SelectSingleNode("SW") != null)
                 officersView.SW = MasonicYearNode["SW"].Attributes[0].InnerText;
             if (MasonicYearNode.SelectSingleNode("JW") != null)
                 officersView.JW = MasonicYearNode["JW"].Attributes[0].InnerText;
             if (MasonicYearNode.SelectSingleNode("SD") != null)
                 officersView.SD = MasonicYearNode["SD"].Attributes[0].InnerText;
             if (MasonicYearNode.SelectSingleNode("JD") != null)
                 officersView.JD = MasonicYearNode["JD"].Attributes[0].InnerText;
             if (MasonicYearNode.SelectSingleNode("TR") != null)
                 officersView.TR = MasonicYearNode["TR"].Attributes[0].InnerText;
             if (MasonicYearNode.SelectSingleNode("SC") != null)
                 officersView.SC = MasonicYearNode["SC"].Attributes[0].InnerText;
             if (MasonicYearNode.SelectSingleNode("TY") != null)
                 officersView.TY = MasonicYearNode["TY"].Attributes[0].InnerText;
             if (MasonicYearNode.SelectSingleNode("SS") != null)
                 officersView.SS = MasonicYearNode["SS"].Attributes[0].InnerText;
             if (MasonicYearNode.SelectSingleNode("JS") != null)
                 officersView.JS = MasonicYearNode["JS"].Attributes[0].InnerText;
             if (MasonicYearNode.SelectSingleNode("MS") != null)
                 officersView.MS = MasonicYearNode["MS"].Attributes[0].InnerText;
             if (MasonicYearNode.SelectSingleNode("MR") != null)
                 officersView.MR = MasonicYearNode["MR"].Attributes[0].InnerText;
             if (MasonicYearNode.SelectSingleNode("CP") != null)
                 officersView.CP = MasonicYearNode["CP"].Attributes[0].InnerText;
         }
     }
     catch (Exception ex) { officersView.MasonicYear = ex.Message; }
     return officersView;
 }
 public string Save(OfficersView officers)
 {
     var lodgeFileName = Server.MapPath("\\App_Data\\") + MasonMasterData.GetUserProfile(User.Identity.Name).DatabaseName;
     return ChairDataXml.AddEditOfficers(officers, lodgeFileName);
 }