コード例 #1
0
ファイル: APIPerson.cs プロジェクト: stevesloka/bvcms
        public string UpdatePersonXml(string xml)
        {
            var x = XDocument.Parse(xml);
            var p = Db.LoadPersonById(x.Root.Attribute("PeopleId").Value.ToInt());
            var u = new APIPerson.Update(p);

            Address2 addr = null;
            foreach (var e in x.Root.Elements())
                switch (e.Name.ToString())
                {
                    case "PersonalAddress":
                        foreach (var pa in e.Elements())
                            u.UpdatePerson(pa);
                        addr = Address2.New(e, p.PeopleId, p.CountryName);
                        addr = ValidateAddress(addr);
                        if (addr.Error.HasValue())
                            return serialize(addr);
                        break;
                    case "FamilyAddress":
                        foreach (var fa in e.Elements())
                            u.UpdateFamily(fa);
                        addr = Address2.New(e, p.PeopleId, p.Family.CountryName);
                        addr = ValidateAddress(addr);
                        if (addr.Error.HasValue())
                            return serialize(addr);
                        break;
                    case "EmContact":
                        p.SetRecReg().Emcontact = e.Value;
                        break;
                    case "EmPhone":
                        p.SetRecReg().Emphone = e.Value;
                        break;
                    default:
                        break;
                }
            foreach (var e in x.Root.Elements())
                switch (e.Name.ToString())
                {
                    case "PersonalAddress":
                    case "FamilyAddress":
                    case "SpouseName":
                    case "FamilyId":
                    case "EmContact":
                    case "EmPhone":
                        break;
                    case "HomePhone":
                        u.UpdateFamily(e);
                        break;
                    default:
                        u.UpdatePerson(e);
                        break;
                }
            p.LogChanges(Db, u.sb);
            p.Family.LogChanges(Db, u.fsb, p.PeopleId, Util.UserPeopleId.Value);
            Db.SubmitChanges();
            return "<Success />";
        }
コード例 #2
0
ファイル: APIPerson.cs プロジェクト: thewruck/bvcms
        public string UpdatePersonXml(string xml)
        {
            var x = XDocument.Parse(xml);
            var p = Db.LoadPersonById(x.Root.Attribute("PeopleId").Value.ToInt());
            var u = new APIPerson.Update(p);

            Address2 addr = null;

            foreach (var e in x.Root.Elements())
            {
                switch (e.Name.ToString())
                {
                case "PersonalAddress":
                    foreach (var pa in e.Elements())
                    {
                        u.UpdatePerson(pa);
                    }
                    addr = Address2.New(e, p.PeopleId, p.CountryName);
                    addr = ValidateAddress(addr);
                    if (addr.Error.HasValue())
                    {
                        return(serialize(addr));
                    }
                    break;

                case "FamilyAddress":
                    foreach (var fa in e.Elements())
                    {
                        u.UpdateFamily(fa);
                    }
                    addr = Address2.New(e, p.PeopleId, p.Family.CountryName);
                    addr = ValidateAddress(addr);
                    if (addr.Error.HasValue())
                    {
                        return(serialize(addr));
                    }
                    break;

                case "EmContact":
                    p.SetRecReg().Emcontact = e.Value;
                    break;

                case "EmPhone":
                    p.SetRecReg().Emphone = e.Value;
                    break;

                default:
                    break;
                }
            }
            foreach (var e in x.Root.Elements())
            {
                switch (e.Name.ToString())
                {
                case "PersonalAddress":
                case "FamilyAddress":
                case "SpouseName":
                case "FamilyId":
                case "EmContact":
                case "EmPhone":
                    break;

                case "HomePhone":
                    u.UpdateFamily(e);
                    break;

                default:
                    u.UpdatePerson(e);
                    break;
                }
            }
            p.LogChanges(Db, u.sb);
            p.Family.LogChanges(Db, u.fsb, p.PeopleId, Util.UserPeopleId.Value);
            Db.SubmitChanges();
            return("<Success />");
        }