public static List<Accomplishment> GetAccomplishments(int masonId, string xmlFileName)
        {
            var memberAccomplishments = new List<Accomplishment>();
            try
            {
                XmlDocument xDoc = new XmlDocument();
                Accomplishment accomplishment;
                xDoc.Load(xmlFileName);
                XmlNodeList accomplishmentNodes = xDoc.SelectNodes("//Members/Member[@MasonId='" + masonId + "']/MemberDetails/MemberDetail");
                if (accomplishmentNodes != null)
                {
                    foreach (XmlNode accomplishmentNode in accomplishmentNodes)
                    {
                        accomplishment = new Accomplishment();
                        accomplishment.MasonId = masonId;
                        accomplishment.AccomplishmentId = accomplishmentNode.Attributes["Id"].InnerText;
                        accomplishment.AccomplishmentType = xDoc.SelectSingleNode("//Refs/refItem[@refCode='" +
                            accomplishmentNode.Attributes["Type"].InnerText + "']").Attributes["refDescription"].InnerText;
                        accomplishment.StartDate = accomplishmentNode.Attributes["StartDate"].InnerText;
                        if (accomplishmentNode.Attributes["EndDate"] != null)
                            accomplishment.EndDate = accomplishmentNode.Attributes["EndDate"].Value;
                        if (accomplishmentNode.SelectSingleNode("ShortTitle") != null)
                            accomplishment.ShortTitle = accomplishmentNode["ShortTitle"].InnerText;
                        if (accomplishmentNode.SelectSingleNode("Location") != null)
                            accomplishment.Location = accomplishmentNode["Location"].InnerText;
                        if (accomplishmentNode.SelectSingleNode("Comments") != null)
                            accomplishment.Comments = accomplishmentNode["Comments"].InnerText;

                        memberAccomplishments.Add(accomplishment);
                    }
                }
            }
            catch (Exception ex) { memberAccomplishments.Add(new Accomplishment { Comments = ex.Message }); }
            return memberAccomplishments;
        }
        public static string xxMemberDetailAddUpdate(Accomplishment model, string connString)
        {
            string success = "ono";
            try
            {
                using (var connection = new System.Data.SqlClient.SqlConnection(connString))
                {
                    connection.Open();
                    using (var command = connection.CreateCommand())
                    {
                        command.CommandText = "lodge.MemberDetailAddUpdate";
                        command.CommandType = System.Data.CommandType.StoredProcedure;

                        command.Parameters.AddWithValue("@MemberDetailId", model.AccomplishmentId);
                        command.Parameters.AddWithValue("@MasonId", model.MasonId);
                        command.Parameters.AddWithValue("@MemberDetailTypeRef", model.AccomplishmentType);
                        command.Parameters.AddWithValue("@ShortTitle", model.ShortTitle);
                        command.Parameters.AddWithValue("@Location", model.Location);
                        command.Parameters.AddWithValue("@StartDate", model.StartDate);
                        command.Parameters.AddWithValue("@EndDate", model.EndDate);
                        command.Parameters.AddWithValue("@Comments", model.Comments);

                        command.ExecuteNonQuery();
                    }
                }
            }
            catch (Exception ex)
            {
                success = ex.Message;
            }
            return success;
        }
 public static Accomplishment GetAccomplishment(int masonId, string memberDetailId, string xmlFileName)
 {
     var accomplishment = new Accomplishment();
     accomplishment.MasonId = masonId;
     try
     {
         XmlDocument xDoc = new XmlDocument();
         xDoc.Load(xmlFileName);
         XmlNode accomplishmentNode = xDoc.SelectSingleNode("//Members/Member[@MasonId='" + masonId + "']/MemberDetails/MemberDetail[@Id='" + memberDetailId + "']");
         if (accomplishmentNode != null)
         {
             accomplishment.AccomplishmentId = accomplishmentNode.Attributes["Id"].InnerText;
             accomplishment.AccomplishmentType = accomplishmentNode.Attributes["Type"].InnerText;
             accomplishment.StartDate = accomplishmentNode.Attributes["StartDate"].InnerText;
             if (accomplishmentNode.Attributes["EndDate"] != null)
                 accomplishment.EndDate = accomplishmentNode.Attributes["EndDate"].Value;
             if (accomplishmentNode.SelectSingleNode("ShortTitle") != null)
                 accomplishment.ShortTitle = accomplishmentNode["ShortTitle"].InnerText;
             if (accomplishmentNode.SelectSingleNode("Location") != null)
                 accomplishment.Location = accomplishmentNode["Location"].InnerText;
             if (accomplishmentNode.SelectSingleNode("Comments") != null)
                 accomplishment.Comments = accomplishmentNode["Comments"].InnerText;
         }
     }
     catch (Exception ex) { accomplishment.Comments = ex.Message; }
     return accomplishment;
 }
        public static string AccomplishmentAddUpdate(Accomplishment memberDetail, string xmlFileName)
        {
            string success = "ono";
            try
            {
                XmlDocument xDoc = new XmlDocument();
                xDoc.Load(xmlFileName);
                XmlNode memberDetailNode = xDoc.SelectSingleNode("//Members/Member[@MasonId='" + memberDetail.MasonId + "']/MemberDetails/MemberDetail[@Id='" + memberDetail.AccomplishmentId + "']");
                if (memberDetailNode == null)
                {
                    XmlNode memberDetailsNode = xDoc.SelectSingleNode("//Members/Member[@MasonId='" + memberDetail.MasonId + "']/MemberDetails");
                    if (memberDetailsNode == null)
                    {
                        XmlNode memberNode = xDoc.SelectSingleNode("//Members/Member[@MasonId='" + memberDetail.MasonId + "']");
                        memberDetailsNode = xDoc.CreateElement("MemberDetails"); memberNode.AppendChild(memberDetailsNode);
                    }
                    memberDetailNode = xDoc.CreateElement("MemberDetail");
                    XmlAttribute Id = xDoc.CreateAttribute("Id"); Id.InnerText = Guid.NewGuid().ToString(); memberDetailNode.Attributes.Append(Id);
                    XmlAttribute TypeId = xDoc.CreateAttribute("Type"); TypeId.InnerText = memberDetail.AccomplishmentType; memberDetailNode.Attributes.Append(TypeId);
                    XmlAttribute StartDate = xDoc.CreateAttribute("StartDate"); StartDate.InnerText = memberDetail.StartDate; memberDetailNode.Attributes.Append(StartDate);
                    if (memberDetail.EndDate != null)
                    { XmlAttribute EndDate = xDoc.CreateAttribute("EndDate"); EndDate.InnerText = memberDetail.EndDate; memberDetailNode.Attributes.Append(EndDate); }
                    if (memberDetail.ShortTitle != null)
                    { XmlNode ShortTitle = xDoc.CreateElement("ShortTitle"); ShortTitle.InnerText = memberDetail.ShortTitle; memberDetailNode.AppendChild(ShortTitle); }
                    if (memberDetail.Location != null)
                    { XmlNode Location = xDoc.CreateElement("Location"); Location.InnerText = memberDetail.Location; memberDetailNode.AppendChild(Location); }
                    if (memberDetail.Comments != null)
                    { XmlNode Comments = xDoc.CreateElement("Comments"); Comments.InnerText = memberDetail.Comments; memberDetailNode.AppendChild(Comments); }
                    memberDetailsNode.AppendChild(memberDetailNode);
                }
                else
                {
                    memberDetailNode.Attributes["Type"].InnerText = memberDetail.AccomplishmentType;
                    memberDetailNode.Attributes["StartDate"].InnerText = memberDetail.StartDate;
                    if (memberDetail.EndDate != null)
                    {
                        if (memberDetailNode.Attributes["EndDate"] == null)
                        { XmlAttribute EndDate = xDoc.CreateAttribute("EndDate"); memberDetailNode.Attributes.Append(EndDate); }
                        memberDetailNode.Attributes["EndDate"].InnerText = memberDetail.EndDate;
                    }
                    if (memberDetail.ShortTitle != null)
                    {
                        if (memberDetailNode.SelectSingleNode("ShortTitle") == null)
                        { XmlNode ShortTitle = xDoc.CreateElement("ShortTitle"); memberDetailNode.AppendChild(ShortTitle); }
                        memberDetailNode["ShortTitle"].InnerText = memberDetail.ShortTitle;
                    }

                    if (memberDetail.Location != null)
                    {
                        if (memberDetailNode.SelectSingleNode("Location") == null)
                        { XmlNode Location = xDoc.CreateElement("Location"); memberDetailNode.AppendChild(Location); }
                        memberDetailNode["Location"].InnerText = memberDetail.Location;
                    }
                    if (memberDetail.Comments != null)
                    {
                        if (memberDetailNode.SelectSingleNode("Comments") == null)
                        { XmlNode Comments = xDoc.CreateElement("Comments"); memberDetailNode.AppendChild(Comments); }
                        memberDetailNode["Comments"].InnerText = memberDetail.Comments;
                    }
                }
                xDoc.Save(xmlFileName);
                success = "ok";
            }
            catch (Exception ex)
            {
                success = ex.Message;
            }
            return success;
        }
 public string SaveAccomplishment(Accomplishment accomplishment)
 {
     string lodgeFileName = Server.MapPath("\\App_Data\\") + MasonMasterData.GetUserProfile(User.Identity.Name).DatabaseName;
     return MemberDataXml.AccomplishmentAddUpdate(accomplishment, lodgeFileName);
 }
 public ActionResult AccomplishmentEdit(int Id, string DetailId)
 {
     var Model = new Accomplishment() { MasonId = Id, AccomplishmentId = DetailId };
     return View("MemberAccomplishments", Model);
 }
 public ActionResult MemberAccomplishments(int Id)
 {
     var lodgeFileName = Server.MapPath("\\App_Data\\") + MasonMasterData.GetUserProfile(User.Identity.Name).DatabaseName;
     var model = new Accomplishment();
     model.FullName = MemberDataXml.GetMember(Id, lodgeFileName).FullName;
     model.MasonId = Id;
     return View(model);
 }