AddEditExtraCode() public method

public AddEditExtraCode ( string field, string value ) : void
field string
value string
return void
Esempio n. 1
0
        private void ProcessExtraValues(CMSDataContext db, Person p, string[] a)
        {
            if (!extravaluenames.Any())
                return;

            foreach (var name in extravaluenames)
            {
                var b = name.Split('.');
                if (name.EndsWith(".txt"))
                    p.AddEditExtraText(b[0], a[names[name]].Trim());
                else if (name.EndsWith(".org"))
                {

                    if (testing)
                        continue;
                    var d = a[names[name]].Trim().Trim();
                    if (!d.HasValue())
                        continue;
                    if (d == "TRUE")
                        d = "Member";
                    var oid = 0;
                    if (orgs.ContainsKey(b[0]))
                        oid = orgs[b[0]];
                    else
                    {
                        var prog = Organization.FetchOrCreateProgram(db, "InsertPeople");
                        var div = Organization.FetchOrCreateDivision(db, prog, "InsertPeople");
                        var o = Organization.FetchOrCreateOrganization(db, div, b[0].SplitUpperCaseToString());
                        oid = o.OrganizationId;
                        orgs.Add(b[0], oid);
                    }
                    var mtid = 0;
                    if (membertypes.ContainsKey(d))
                        mtid = membertypes[d];
                    else
                    {
                        var mt = Organization.FetchOrCreateMemberType(db, d);
                        mtid = mt.Id;
                        membertypes.Add(d, mtid);
                    }
                    OrganizationMember.InsertOrgMembers(db, oid, p.PeopleId, mtid, DateTime.Today, null, false);
                }
                else if (name.EndsWith(".dt"))
                {
                    var d = a[names[name]].Trim().ToDate();
                    if (d.HasValue)
                        p.AddEditExtraDate(b[0], d.Value);
                }
                else if (name.EndsWith(".int"))
                    p.AddEditExtraInt(b[0], a[names[name]].Trim().ToInt());
                else if (name.EndsWith(".bit"))
                {
                    var v = a[names[name]];
                    if (v.HasValue())
                        p.AddEditExtraBool(b[0], v.ToInt() == 1);
                }
                else
                    p.AddEditExtraCode(name, a[names[name]].Trim());
            }
        }