Exemplo n.º 1
0
        public static OrganizationType FetchOrCreateType(CMSDataContext Db, string type)
        {
            var t = Db.OrganizationTypes.SingleOrDefault(pp => pp.Description == type);

            if (t == null)
            {
                var max = 10;
                if (Db.OrganizationTypes.Any())
                {
                    max = Db.OrganizationTypes.Max(mm => mm.Id) + 10;
                }
                t = new OrganizationType {
                    Description = type, Code = type.Substring(0, 3), Id = max
                };
                Db.OrganizationTypes.InsertOnSubmit(t);
                Db.SubmitChanges();
            }
            return(t);
        }
Exemplo n.º 2
0
 public static OrganizationType FetchOrCreateType(CMSDataContext Db, string type)
 {
     var t = Db.OrganizationTypes.SingleOrDefault(pp => pp.Description == type);
     if (t == null)
     {
         var max = 10;
         if (Db.OrganizationTypes.Any())
             max = Db.OrganizationTypes.Max(mm => mm.Id) + 10;
         t = new OrganizationType { Description = type, Code = type.Substring(0, 3), Id = max };
         Db.OrganizationTypes.InsertOnSubmit(t);
         Db.SubmitChanges();
     }
     return t;
 }