Esempio n. 1
0
        internal static String Save(DB.CAT_Meta entry, DataContext dataContext)
        {
            try
            {
                if (dataContext.EntityCatalogueContext.GetEntityState(entry) == System.Data.Entity.EntityState.Detached)
                {
                    dataContext.EntityCatalogueContext.CAT_Meta.Add(entry);
                }
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException ex)
            {
                return(dataContext.PackageValidationException());
            }

            return("Success");
        }
Esempio n. 2
0
        private void btnAddMeta_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            try
            {
                DB.CAT_Meta newMeta = BL.CAT.CAT_Meta.New;
                newMeta.CategoryId = ((DB.CAT_Category)tlCategory.GetDataRecordByNode(tlCategory.FocusedNode)).Id;
                newMeta.SortOrder  = BindingSourceMeta.Count + 1;
                BL.EntityController.SaveCAT_Meta(newMeta, DataContext);
                //Werner
                //I realy dont want to do this but if the Category does not have an ID you cant place a child under it
                //Need to find a way to do it in some kind of transaction to reserve the IDs but should be able to rollback
                OnSaveRecord();
                BindingSourceMeta.Add(newMeta);

                DataContext.EntityCatalogueContext.Database.ExecuteSqlCommand(String.Format("INSERT INTO [CDS_CAT].CAT_MetaData {0} SELECT DISTINCT [CDS_CAT].CAT_Meta.Id, [CDS_CAT].CAT_ItemData.ItemId, [CDS_CAT].CAT_Category.Id, '', GETDATE(), 1 FROM [CDS_CAT].CAT_Category INNER JOIN [CDS_CAT].CAT_Meta on [CDS_CAT].CAT_Category.Id = [CDS_CAT].CAT_Meta.CategoryId INNER JOIN [CDS_CAT].CAT_ItemData ON [CDS_CAT].CAT_ItemData.CategoryId = [CDS_CAT].CAT_Category.Id LEFT JOIN [CDS_CAT].CAT_MetaData ON [CDS_CAT].CAT_MetaData.MetaId = [CDS_CAT].CAT_Meta.Id AND [CDS_CAT].CAT_MetaData.CategoryId = [CDS_CAT].CAT_Category.Id WHERE Data IS NULL AND [CDS_CAT].CAT_Meta.Id = {1}", Environment.NewLine, newMeta.Id));
            }
            catch (Exception ex)
            {
                if (CDS.Shared.Exception.UserInterfaceExceptionHandler.HandleException(ref ex))
                {
                    throw ex;
                }
            }
        }