예제 #1
0
        public static Person CreateNewPerson(
            string titulPred, string jmeno, string prijmeni, string titulPo,
            string narozeni, StatusOsobyEnum status
            )
        {
            Person p = new Data.Person();

            p.TitulPred    = NormalizeTitul(titulPred, true);
            p.TitulPo      = NormalizeTitul(titulPo, false);
            p.Jmeno        = NormalizeJmeno(jmeno);
            p.Prijmeni     = NormalizePrijmeni(prijmeni);
            p.PersonStatus = (int)status;
            p.Narozeni     = null;
            DateTime o;

            if (DateTime.TryParseExact(narozeni, "d.M.yyyy", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out o)) //28.3.1955
            {
                p.Narozeni = o;
            }
            else if (DateTime.TryParseExact(narozeni, "dd.MM.yyyy", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out o)) //28.03.1955
            {
                p.Narozeni = o;
            }
            else if (DateTime.TryParseExact(narozeni, "dd.MM.yy", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out o)) //28.03.55
            {
                p.Narozeni = o;
            }



            return(p);
        }
예제 #2
0
        public static Osoba GetOrCreateNew(string titulPred, string jmeno, string prijmeni, string titulPo,
                                           DateTime?narozeni, StatusOsobyEnum status, string user)
        {
            var p = new Data.Osoba();

            p.TitulPred = NormalizeTitul(titulPred, true);
            p.TitulPo   = NormalizeTitul(titulPo, false);
            p.Jmeno     = NormalizeJmeno(jmeno);
            p.Prijmeni  = NormalizePrijmeni(prijmeni);

            if (narozeni.HasValue == false)
            {
                p.Status = (int)status;
                p.Save();
                Audit.Add(Audit.Operations.Create, user, p, null);
                return(p);
            }
            var exiO = Osoba.GetByName(p.Jmeno, p.Prijmeni, narozeni.Value);


            if (exiO == null)
            {
                p.Status   = (int)status;
                p.Narozeni = narozeni;
                p.Save();
                Audit.Add(Audit.Operations.Create, user, p, null);
                return(p);
            }
            else
            {
                bool changed = false;
                if (exiO.TitulPred != p.TitulPred)
                {
                    changed        = true;
                    exiO.TitulPred = p.TitulPred;
                }
                if (exiO.TitulPo != p.TitulPo)
                {
                    changed      = true;
                    exiO.TitulPo = p.TitulPo;
                }
                if (exiO.Status < (int)status)
                {
                    changed     = true;
                    exiO.Status = (int)status;
                }
                if (changed)
                {
                    exiO.Save();
                    Audit.Add(Audit.Operations.Update, user, exiO, Osoba.Get(exiO.InternalId));
                }
                return(exiO);
            }
        }
예제 #3
0
 public static Osoba GetOrCreateNew(string titulPred, string jmeno, string prijmeni, string titulPo,
                                    string narozeni, StatusOsobyEnum status, string user
                                    )
 {
     return(GetOrCreateNew(titulPred, jmeno, prijmeni, titulPo, ParseTools.ToDateTimeFromCZ(narozeni), status, user));
 }