Exemple #1
0
        public int UpdateEntityRelationshipTailDataMenu(EntityRelationshipTailDataMenuDTO message)
        {
            using (var projectContext = new DataAccess.MyProjectEntities())
            {
                EntityRelationshipTailDataMenu dbItem = null;
                if (message.ID == 0)
                {
                    dbItem = new EntityRelationshipTailDataMenu();
                    projectContext.EntityRelationshipTailDataMenu.Add(dbItem);
                }
                else
                {
                    dbItem = projectContext.EntityRelationshipTailDataMenu.First(x => x.ID == message.ID);
                }

                dbItem.Name = message.Name;
                dbItem.EntityRelationshipTailID = message.EntityRelationshipTailID;
                while (dbItem.EntityRelationshipTailDataMenuItems.Any())
                {
                    projectContext.EntityRelationshipTailDataMenuItems.Remove(dbItem.EntityRelationshipTailDataMenuItems.First());
                }
                foreach (var fitem in message.Items.Where(x => x.DataMenuSettingID != 0))
                {
                    dbItem.EntityRelationshipTailDataMenuItems.Add(new EntityRelationshipTailDataMenuItems()
                    {
                        DataMenuSettingID = fitem.DataMenuSettingID,
                        Path = fitem.Path,
                        TableDrivedEntityID = fitem.TableDrivedEntityID
                    });
                }
                projectContext.SaveChanges();
                return(dbItem.ID);
            }
        }
Exemple #2
0
        public void UpdateEntityOrganizationSecurityDirect(EntityOrganizationSecurityDirectDTO message)
        {
            using (var projectContext = new DataAccess.MyProjectEntities())
            {
                var dbItem = projectContext.EntityOrganizationSecurityDirect.FirstOrDefault(x => x.ID == message.ID);
                if (dbItem == null)
                {
                    dbItem = new DataAccess.EntityOrganizationSecurityDirect();
                    projectContext.EntityOrganizationSecurityDirect.Add(dbItem);
                }
                dbItem.TableDrivedEntityID = message.TableDrivedEntityID;

                dbItem.ColumnID = message.ColumnID;
                if (message.DBFunctionID != 0)
                {
                    dbItem.DatabaseFunctionID = message.DBFunctionID;
                    dbItem.Operator           = (short)message.Operator;
                }
                else
                {
                    dbItem.DatabaseFunctionID = null;
                    dbItem.Operator           = null;
                }
                projectContext.SaveChanges();
            }
        }
Exemple #3
0
        public bool UpdateArchiveFolder(ArchiveFolderDTO message)
        {
            List <ArchiveFolderDTO> result = new List <ArchiveFolderDTO>();

            using (var projectContext = new DataAccess.MyProjectEntities())
            {
                ArchiveFolder dbitem = null;
                if (message.ID != 0)
                {
                    dbitem = projectContext.ArchiveFolder.First(x => x.ID == message.ID);
                }
                else
                {
                    dbitem = new ArchiveFolder();
                }
                dbitem.Name = message.Name;
                dbitem.TableDrivedEntityID = (message.EntityID == 0 ? (int?)null : message.EntityID);
                if (dbitem.ID == 0)
                {
                    projectContext.ArchiveFolder.Add(dbitem);
                }
                projectContext.SaveChanges();
            }
            return(true);
        }
Exemple #4
0
        public int Save(ISARelationshipDTO item)
        {
            using (var projectContext = new DataAccess.MyProjectEntities())
            {
                ISARelationship dbItem = null;
                if (item.ID == 0)
                {
                    dbItem = new ISARelationship();
                    projectContext.ISARelationship.Add(dbItem);
                }
                else
                {
                    dbItem = projectContext.ISARelationship.First(x => x.ID == item.ID);
                }

                dbItem.Name          = item.Name;
                dbItem.IsDisjoint    = item.IsDisjoint;
                dbItem.InternalTable = item.InternalTable == true;
                //dbItem.InternalTableColumnID = item.InternalTableColumnID == 0 ? (int?)null : item.InternalTableColumnID;
                dbItem.IsGeneralization     = item.IsGeneralization;
                dbItem.IsSpecialization     = !item.IsSpecialization;
                dbItem.IsTolatParticipation = item.IsTolatParticipation;
                projectContext.SaveChanges();
                return(dbItem.ID);
            }
        }
 //public bool AddCodeFunctionToEntity(int codefuntionID, int entityID, bool showInFormula)
 //{
 //    using (var projectContext = new DataAccess.MyProjectEntities())
 //    {
 //        var dbCodeFunctionEntity = projectContext.CodeFunction_TableDrivedEntity.FirstOrDefault(x => x.TableDrivedEntityID == entityID && x.CodeFunctionID == codefuntionID);
 //        if (dbCodeFunctionEntity == null)
 //        {
 //            projectContext.CodeFunction_TableDrivedEntity.Add(new CodeFunction_TableDrivedEntity() { CodeFunctionID = codefuntionID, TableDrivedEntityID = entityID, ShowInFormula = showInFormula });
 //        }
 //        else
 //        {
 //            dbCodeFunctionEntity.ShowInFormula = showInFormula;
 //        }
 //        projectContext.SaveChanges();
 //    }
 //    return true;
 //}
 public int UpdateCodeFunctionEntity(CodeFunction_EntityDTO CodeFunctionEntity)
 {
     using (var projectContext = new DataAccess.MyProjectEntities())
     {
         var dbCodeFunctionEntity = projectContext.CodeFunction_TableDrivedEntity.FirstOrDefault(x => x.ID == CodeFunctionEntity.ID);
         if (dbCodeFunctionEntity == null)
         {
             dbCodeFunctionEntity = new CodeFunction_TableDrivedEntity();
         }
         dbCodeFunctionEntity.CodeFunctionID      = CodeFunctionEntity.CodeFunctionID;
         dbCodeFunctionEntity.TableDrivedEntityID = CodeFunctionEntity.EntityID;
         dbCodeFunctionEntity.Title = CodeFunctionEntity.Title;
         dbCodeFunctionEntity.Name  = CodeFunctionEntity.Name;
         while (dbCodeFunctionEntity.CodeFunction_TableDrivedEntity_Parameters.Any())
         {
             projectContext.CodeFunction_TableDrivedEntity_Parameters.Remove(dbCodeFunctionEntity.CodeFunction_TableDrivedEntity_Parameters.First());
         }
         //if (!CodeFunctionEntity.CodeFunctionEntityColumns.Any(x => x.ColumnID == 0))
         //{
         foreach (var column in CodeFunctionEntity.CodeFunctionEntityColumns)
         {
             CodeFunction_TableDrivedEntity_Parameters dbColumn = new DataAccess.CodeFunction_TableDrivedEntity_Parameters();
             dbColumn.ColumnID = column.ColumnID;
             dbColumn.CodeFunctionParameterID = column.CodeFunctionParameterID;
             dbCodeFunctionEntity.CodeFunction_TableDrivedEntity_Parameters.Add(dbColumn);
         }
         //}
         if (dbCodeFunctionEntity.ID == 0)
         {
             projectContext.CodeFunction_TableDrivedEntity.Add(dbCodeFunctionEntity);
         }
         projectContext.SaveChanges();
         return(dbCodeFunctionEntity.ID);
     }
 }
Exemple #6
0
 public int SaveDatabase(DatabaseDTO message)
 {
     using (var projectContext = new DataAccess.MyProjectEntities())
     {
         var dbDatabase = projectContext.DatabaseInformation.FirstOrDefault(x => x.ID == message.ID);
         if (dbDatabase == null)
         {
             dbDatabase = new DatabaseInformation();
             dbDatabase.SecurityObject      = new SecurityObject();
             dbDatabase.SecurityObject.Type = (int)DatabaseObjectCategory.Database;
         }
         dbDatabase.DBServerID       = message.DBServerID;
         dbDatabase.Name             = message.Name;
         dbDatabase.Title            = message.Title;
         dbDatabase.DBHasDate        = message.DBHasData;
         dbDatabase.ConnectionString = message.ConnectionString;
         dbDatabase.DBType           = message.DBType.ToString();
         if (dbDatabase.ID == 0)
         {
             projectContext.DatabaseInformation.Add(dbDatabase);
         }
         projectContext.SaveChanges();
         return(dbDatabase.ID);
     }
 }
Exemple #7
0
 public void MergeISARelationships(string name, List <ISARelationshipDTO> relationships, ISARelationshipDTO selectedOne)
 {
     using (var projectContext = new DataAccess.MyProjectEntities())
     {
         int isaRelationID = 0;
         foreach (var relationship in relationships)
         {
             //if (relationship == selectedOne)
             //    isaRelationID = relationship.ID;
             //else
             //{
             var dbRelationship = projectContext.ISARelationship.First(x => x.ID == relationship.ID);
             foreach (var detail in dbRelationship.SuperToSubRelationshipType)
             {
                 detail.ISARelationshipID = selectedOne.ID;
             }
             foreach (var detail in dbRelationship.SubToSuperRelationshipType)
             {
                 detail.ISARelationshipID = selectedOne.ID;
             }
             //}
         }
         projectContext.SaveChanges();
     }
 }
Exemple #8
0
 public void UpdateDateTimeColumnType(List <DateTimeColumnTypeDTO> columnTypes)
 {
     using (var projectContext = new DataAccess.MyProjectEntities())
     {
         foreach (var column in columnTypes)
         {
             var dbColumn = projectContext.DateTimeColumnType.First(x => x.ColumnID == column.ColumnID);
             dbColumn.ShowMiladiDateInUI = column.ShowMiladiDateInUI;
             dbColumn.ShowAMPMFormat     = column.ShowAMPMFormat;
             dbColumn.HideTimePicker     = column.HideTimePicker;
             if ((Enum_ColumnType)dbColumn.Column.OriginalTypeEnum == Enum_ColumnType.String)
             {
                 dbColumn.StringDateIsMiladi     = column.StringDateIsMiladi;
                 dbColumn.StringTimeISAMPMFormat = column.StringTimeISAMPMFormat;
                 dbColumn.StringTimeIsMiladi     = column.StringTimeIsMiladi;
             }
             else
             {
                 dbColumn.StringDateIsMiladi     = null;
                 dbColumn.StringTimeISAMPMFormat = null;
                 dbColumn.StringTimeIsMiladi     = null;
             }
         }
         projectContext.SaveChanges();
     }
 }
 public void UpdateEntityActionActivities(int entityId, List <EntityActionActivityDTO> entityActionActivities)
 {
     using (var projectContext = new DataAccess.MyProjectEntities())
     {
         var dbEntityActionActivities = projectContext.ActionActivity_TableDrivedEntity.Where(x => x.TableDrivedEntityID == entityId);
         var sentIds    = entityActionActivities.Select(y => y.ID).ToList();
         var removeList = dbEntityActionActivities.Where(x => !sentIds.Contains(x.ID)).ToList();
         foreach (var item in removeList)
         {
             projectContext.ActionActivity_TableDrivedEntity.Remove(item);
         }
         foreach (var entityActionActivity in entityActionActivities)
         {
             var dbEntityActionActivity = projectContext.ActionActivity_TableDrivedEntity.FirstOrDefault(x => x.ID == entityActionActivity.ID);
             if (dbEntityActionActivity == null)
             {
                 dbEntityActionActivity = new DataAccess.ActionActivity_TableDrivedEntity();
             }
             dbEntityActionActivity.StepType            = (short)entityActionActivity.Step;
             dbEntityActionActivity.ActionActivityID    = entityActionActivity.ActionActivityID;
             dbEntityActionActivity.TableDrivedEntityID = entityId;
             dbEntityActionActivity.ID = entityActionActivity.ID;
             dbEntityActionActivity.ResultSensetive = entityActionActivity.ResultSensetive;
             if (dbEntityActionActivity.ID == 0)
             {
                 projectContext.ActionActivity_TableDrivedEntity.Add(dbEntityActionActivity);
             }
         }
         projectContext.SaveChanges();
     }
 }
Exemple #10
0
 public void UpdateSuperUnionToSubUnionRelationships(List <UnionToSubUnionRelationshipDTO> relationships)
 {
     using (var projectContext = new DataAccess.MyProjectEntities())
     {
         foreach (var relationship in relationships)
         {
             var dbRelationship = projectContext.UnionToSubUnionRelationshipType.First(x => x.ID == relationship.ID);
             dbRelationship.RelationshipType.IsOtherSideCreatable         = relationship.IsOtherSideCreatable;
             dbRelationship.RelationshipType.IsOtherSideDirectlyCreatable = relationship.IsOtherSideDirectlyCreatable;
             //dbRelationship.RelationshipType.IsOtherSideTransferable = relationship.IsOtherSideTransferable;
             dbRelationship.RelationshipType.Relationship.Name  = relationship.Name;
             dbRelationship.RelationshipType.Relationship.Alias = relationship.Alias;
             dbRelationship.DeterminerColumnValue = relationship.DeterminerColumnValue;
             if (relationship.DeterminerColumnID != 0)
             {
                 dbRelationship.DeterminerColumnID = relationship.DeterminerColumnID;
             }
             else
             {
                 dbRelationship.DeterminerColumnID = null;
             }
         }
         projectContext.SaveChanges();
     }
 }
Exemple #11
0
 public void UpdateTimeColumnType(List <TimeColumnTypeDTO> columnTypes)
 {
     using (var projectContext = new DataAccess.MyProjectEntities())
     {
         foreach (var column in columnTypes)
         {
             var dbColumn = projectContext.TimeColumnType.First(x => x.ColumnID == column.ColumnID);
             //if (!column.StringValueIsMiladi)
             //{
             //    if ((Enum_ColumnType)dbColumn.Column.OriginalTypeEnum == Enum_ColumnType.Time)
             //    {
             //        throw new Exception("ستون از نوع زمان می باشد و گزینه مقدار شمسی به اشتباه انتخاب شده است");
             //    }
             //}
             dbColumn.ShowMiladiTime = column.ShowMiladiTime;
             dbColumn.ShowAMPMFormat = column.ShowAMPMFormat;
             if ((Enum_ColumnType)dbColumn.Column.OriginalTypeEnum == Enum_ColumnType.String)
             {
                 dbColumn.StringTimeIsMiladi     = column.StringTimeIsMiladi;
                 dbColumn.StringTimeISAMPMFormat = column.StringTimeISAMPMFormat;
             }
             else
             {
                 dbColumn.StringTimeIsMiladi     = null;
                 dbColumn.StringTimeISAMPMFormat = null;
             }
         }
         projectContext.SaveChanges();
     }
 }
Exemple #12
0
 public void MergeUnionRelationships(string name, List <UnionRelationshipDTO> relationships, UnionRelationshipDTO selectedOne)
 {
     using (var projectContext = new DataAccess.MyProjectEntities())
     {
         //   int UnionRelationID = 0;
         foreach (var relationship in relationships)
         {
             //if (relationship == selectedOne)
             //    UnionRelationID = relationship.ID;
             //else
             //{
             var dbRelationship = projectContext.UnionRelationshipType.First(x => x.ID == relationship.ID);
             foreach (var detail in dbRelationship.UnionToSubUnionRelationshipType)
             {
                 detail.UnionRelationshipTypeID = selectedOne.ID;
             }
             foreach (var detail in dbRelationship.SubUnionToUnionRelationshipType)
             {
                 detail.UnionRelationshipTypeID = selectedOne.ID;
             }
             //}
         }
         projectContext.SaveChanges();
     }
 }
        public void Save(int entityID, List <EntityUICompositionDTO> items)
        {
            using (var projectContext = new DataAccess.MyProjectEntities())
            {
                SaveItem(projectContext, entityID, items);

                try
                {
                    projectContext.SaveChanges();
                }
                catch (System.Data.Entity.Validation.DbEntityValidationException e)
                {
                    foreach (var eve in e.EntityValidationErrors)
                    {
                        Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                          eve.Entry.Entity.GetType().Name, eve.Entry.State);
                        foreach (var ve in eve.ValidationErrors)
                        {
                            Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                              ve.PropertyName, ve.ErrorMessage);
                        }
                    }
                    throw;
                }
            }
        }
        public bool UpdateColumnValueRange(ColumnValueRangeDTO message)
        {
            using (var projectContext = new DataAccess.MyProjectEntities())
            {
                var dbColumn = projectContext.Column.First(x => x.ID == message.ID);

                if (dbColumn.ColumnValueRange == null)
                {
                    dbColumn.ColumnValueRange = new ColumnValueRange();
                    //  projectContext.ColumnValueRange.Add(dbColumnValueRange);
                }
                //else
                //    dbColumnValueRange = projectContext.ColumnValueRange.First(x => x.ID == message.ID);
                //     dbColumnValueRange.ID = message.ID;
                //dbColumn.ColumnValueRange.ValueFromTitleOrValue = message.ValueFromTitleOrValue;
                while (dbColumn.ColumnValueRange.ColumnValueRangeDetails.Any())
                {
                    projectContext.ColumnValueRangeDetails.Remove(dbColumn.ColumnValueRange.ColumnValueRangeDetails.First());
                }
                foreach (var keyValueRange in message.Details)
                {
                    dbColumn.ColumnValueRange.ColumnValueRangeDetails.Add(new ColumnValueRangeDetails()
                    {
                        Value = keyValueRange.Value, KeyTitle = keyValueRange.KeyTitle, Tag1 = keyValueRange.Tag1, Tag2 = keyValueRange.Tag2
                    });
                }
                //dbColumnValueRange.Name = message.Name;
                projectContext.SaveChanges();
                return(true);
            }
        }
Exemple #15
0
        public void UpdateEntityExternalReports(DR_Requester requester, EntityExternalReportDTO message)
        {
            using (var projectContext = new DataAccess.MyProjectEntities())
            {
                BizEntityReport bizEntityReport = new MyModelManager.BizEntityReport();

                var dbEntitySpecifiedReport = projectContext.EntityExternalReport.FirstOrDefault(x => x.ID == message.ID);
                if (dbEntitySpecifiedReport == null)
                {
                    message.ReportType           = ReportType.SearchableReport;
                    message.SearchableReportType = SearchableReportType.ExternalReport;
                    dbEntitySpecifiedReport      = new EntityExternalReport();
                    dbEntitySpecifiedReport.EntitySearchableReport = bizEntitySearchableReport.ToNewEntitySearchableReport(message);
                }
                else
                {
                    bizEntitySearchableReport.ToUpdateEntitySearchableReport(dbEntitySpecifiedReport.EntitySearchableReport, message);
                }

                dbEntitySpecifiedReport.URL = message.URL;
                if (dbEntitySpecifiedReport.ID == 0)
                {
                    projectContext.EntityExternalReport.Add(dbEntitySpecifiedReport);
                }

                var entity = new BizTableDrivedEntity().GetSimpleEntityWithColumns(requester, message.TableDrivedEntityID);
                CreateReportTable(entity);
                //ساختن جدول معادل

                projectContext.SaveChanges();
            }
        }
 public void DeleteBackendActionActivity(int iD)
 {
     using (var projectContext = new DataAccess.MyProjectEntities())
     {
         var dbBackendActionActivity = projectContext.BackendActionActivity.FirstOrDefault(x => x.ID == iD);
         projectContext.BackendActionActivity.Remove(dbBackendActionActivity);
         projectContext.SaveChanges();
     }
 }
 public int UpdateEntitySearchs(EntitySearchDTO message)
 {
     using (var projectContext = new DataAccess.MyProjectEntities())
     {
         var dbItem = SaveItem(projectContext, message);
         projectContext.SaveChanges();
         return(dbItem.ID);
     }
 }
Exemple #18
0
 public bool SetDefaultDataMenuSetting(int entityID, int iD)
 {
     using (var projectContext = new DataAccess.MyProjectEntities())
     {
         var dbEntity = projectContext.TableDrivedEntity.FirstOrDefault(x => x.ID == entityID);
         dbEntity.DataMenuSettingID = iD;
         projectContext.SaveChanges();
     }
     return(true);
 }
        public int UpdateBackendActionActivitys(BackendActionActivityDTO BackendActionActivity)
        {
            using (var projectContext = new DataAccess.MyProjectEntities())
            {
                var dbBackendActionActivity = projectContext.BackendActionActivity.FirstOrDefault(x => x.ID == BackendActionActivity.ID);
                if (dbBackendActionActivity == null)
                {
                    dbBackendActionActivity = new DataAccess.BackendActionActivity();
                }



                if (BackendActionActivity.CodeFunctionID != 0)
                {
                    dbBackendActionActivity.CodeFunctionID = BackendActionActivity.CodeFunctionID;
                }
                else
                {
                    dbBackendActionActivity.CodeFunctionID = null;
                }

                if (BackendActionActivity.DatabaseFunctionEntityID != 0)
                {
                    dbBackendActionActivity.DatabaseFunctionEntityID = BackendActionActivity.DatabaseFunctionEntityID;
                }
                else
                {
                    dbBackendActionActivity.DatabaseFunctionEntityID = null;
                }



                dbBackendActionActivity.ID   = BackendActionActivity.ID;
                dbBackendActionActivity.Type = (short)BackendActionActivity.Type;
                //dbBackendActionActivity.ActivityType = (short)BackendActionActivity.BackendActionActivityType;
                dbBackendActionActivity.Title = BackendActionActivity.Title;
                if (BackendActionActivity.EntityID == 0)
                {
                    dbBackendActionActivity.TableDrivedEntityID = null;
                }
                else
                {
                    dbBackendActionActivity.TableDrivedEntityID = BackendActionActivity.EntityID;
                }
                dbBackendActionActivity.StepType        = (short)BackendActionActivity.Step;
                dbBackendActionActivity.ResultSensetive = BackendActionActivity.ResultSensetive;
                if (dbBackendActionActivity.ID == 0)
                {
                    projectContext.BackendActionActivity.Add(dbBackendActionActivity);
                }
                projectContext.SaveChanges();
                return(dbBackendActionActivity.ID);
            }
        }
Exemple #20
0
        public void UpdateEntityCommands(EntityCommandDTO EntityCommand)
        {
            using (var projectContext = new DataAccess.MyProjectEntities())
            {
                var dbEntityCommand = projectContext.EntityCommand.FirstOrDefault(x => x.ID == EntityCommand.ID);
                if (dbEntityCommand == null)
                {
                    dbEntityCommand = new DataAccess.EntityCommand();
                    dbEntityCommand.SecurityObject      = new SecurityObject();
                    dbEntityCommand.SecurityObject.Type = (int)DatabaseObjectCategory.Command;
                }
                //if (EntityCommand.FormulaID != 0)
                //    dbEntityCommand.FormulaID = EntityCommand.FormulaID;
                //else
                //    dbEntityCommand.FormulaID = null;
                //if (EntityCommand.CodeFunctionID != 0)
                //{
                dbEntityCommand.CodeFunctionID = EntityCommand.CodeFunctionID;

                //}
                //else
                //    dbEntityCommand.CodeFunctionID = null;
                //    dbEntityCommand.TableDrivedEntityID = EntityCommand.TableDrivedEntityID;
                dbEntityCommand.ID = EntityCommand.ID;
                //dbEntityCommand.Message = EntityCommand.Message;
                dbEntityCommand.Title = EntityCommand.Title;
                dbEntityCommand.Type  = (short)EntityCommand.Type;

                var entityIds  = EntityCommand.Entities.Select(x => x.EntityID).ToList();
                var removeList = dbEntityCommand.TableDrivedEntity_EntityCommand.Where(x => !entityIds.Contains(x.TableDrivedEntityID));
                foreach (var item in removeList)
                {
                    projectContext.TableDrivedEntity_EntityCommand.Remove(item);
                }
                foreach (var item in entityIds)
                {
                    if (!dbEntityCommand.TableDrivedEntity_EntityCommand.Any(x => x.TableDrivedEntityID == item))
                    {
                        dbEntityCommand.TableDrivedEntity_EntityCommand.Add(new TableDrivedEntity_EntityCommand()
                        {
                            TableDrivedEntityID = item
                        });
                    }
                }
                //dbEntityCommand.Value = EntityCommand.Value;
                if (dbEntityCommand.ID == 0)
                {
                    projectContext.EntityCommand.Add(dbEntityCommand);
                }
                projectContext.SaveChanges();
            }
        }
 public void Save(List <DatabaseFunctionDTO> list)
 {
     using (var projectContext = new DataAccess.MyProjectEntities())
     {
         foreach (var dbFunction in list)
         {
             var dbEntity = projectContext.DatabaseFunction.First(x => x.ID == dbFunction.ID);
             dbEntity.Title = dbFunction.Title;
             //dbEntity.ValueCustomType = (short)dbFunction.ValueCustomType;
         }
         projectContext.SaveChanges();
     }
 }
Exemple #22
0
        //public FormulaDTO GetCustomCalculationFormula(int columnID)
        //{
        //    using (var projectContext = new DataAccess.MyProjectEntities())
        //    {
        //        var column = projectContext.Column.FirstOrDefault(x => x.ID == columnID);
        //        if (column.CustomCalculatedColumn != null)
        //            return new BizFormula().GetFormula(column.CustomCalculatedColumn.FormulaID, false);
        //    }
        //    return null;
        //}



        public void UpdateColumns(int entityID, List <ColumnDTO> columns)
        {
            using (var projectContext = new DataAccess.MyProjectEntities())
            {
                var dbEntity = projectContext.TableDrivedEntity.First(x => x.ID == entityID);
                dbEntity.ColumnsReviewed = true;
                foreach (var column in columns)
                {
                    var dbColumn = projectContext.Column.First(x => x.ID == column.ID);
                    dbColumn.Alias        = column.Alias;
                    dbColumn.DefaultValue = column.DefaultValue;
                    dbColumn.IsMandatory  = column.IsMandatory;
                    dbColumn.Position     = column.Position;
                    dbColumn.Description  = column.Description;
                    if (column.PrimaryKey || column.ForeignKey)
                    {
                    }
                    else
                    {
                        dbColumn.IsDisabled        = column.IsDisabled;
                        dbColumn.IsReadonly        = column.IsReadonly;
                        dbColumn.DataEntryEnabled  = column.DataEntryEnabled;
                        dbColumn.IsNotTransferable = column.IsNotTransferable;
                    }

                    //if(dbEntity.IsView)
                    //{
                    //    dbColumn.PrimaryKey = column.PrimaryKey;
                    //}



                    // if (column.CustomFormulaID != 0)
                    // {
                    //     //if (dbColumn.CustomCalculatedColumn == null)
                    //     //    dbColumn.CustomCalculatedColumn = new CustomCalculatedColumn();
                    //     //dbColumn.CustomCalculatedColumn.FormulaID = column.CustomFormulaID;
                    //     //dbColumn.IsCustomColumn = true;
                    // }
                    // else
                    // {
                    ////     dbColumn.IsCustomColumn = false;
                    //     //if (dbColumn.CustomCalculatedColumn != null)
                    //     //{
                    //     //    projectContext.CustomCalculatedColumn.Remove(dbColumn.CustomCalculatedColumn);
                    //     //}
                    // }
                }
                projectContext.SaveChanges();
            }
        }
        public bool DeleteEntitySecurityDirect(int id)
        {
            EntitySecurityDirectDTO result = new EntitySecurityDirectDTO();

            using (var projectContext = new DataAccess.MyProjectEntities())
            {
                var item = projectContext.EntitySecurityDirect.FirstOrDefault(x => x.ID == id);
                //foreach (var child in item.EntitySecurityDirectStates.ToList())
                //    projectContext.EntitySecurityDirectStates.Remove(child);
                projectContext.EntitySecurityDirect.Remove(item);
                projectContext.SaveChanges();
                return(true);
            }
        }
Exemple #24
0
 public void UpdateStringColumnType(List <StringColumnTypeDTO> columnTypes)
 {
     using (var projectContext = new DataAccess.MyProjectEntities())
     {
         foreach (var column in columnTypes)
         {
             var dbColumn = projectContext.StringColumnType.First(x => x.ColumnID == column.ColumnID);
             dbColumn.MaxLength = column.MaxLength;
             dbColumn.MinLength = column.MinLength;
             dbColumn.Format    = column.Format;
         }
         projectContext.SaveChanges();
     }
 }
Exemple #25
0
        public void DeleteColumnCustomFormula(int columnID)
        {
            using (var projectContext = new DataAccess.MyProjectEntities())
            {
                var dbColumn = projectContext.Column.First(x => x.ID == columnID);


                if (dbColumn.ColumnCustomFormula == null)
                {
                    projectContext.ColumnCustomFormula.Remove(dbColumn.ColumnCustomFormula);
                }
                projectContext.SaveChanges();
            }
        }
Exemple #26
0
 public int UpdateEntityListViews(EntityListViewDTO message)
 {
     using (var projectContext = new DataAccess.MyProjectEntities())
     {
         var dbEntityListView = SaveItem(projectContext, message);
         try
         {
             projectContext.SaveChanges();
         }
         catch (Exception ex)
         {
         }
         return(dbEntityListView.ID);
     }
 }
Exemple #27
0
 public void UpdateNumericColumnType(List <NumericColumnTypeDTO> columnTypes)
 {
     using (var projectContext = new DataAccess.MyProjectEntities())
     {
         foreach (var column in columnTypes)
         {
             var dbColumn = projectContext.NumericColumnType.First(x => x.ColumnID == column.ColumnID);
             dbColumn.MaxValue  = column.MaxValue;
             dbColumn.MinValue  = column.MinValue;
             dbColumn.Precision = column.Precision;
             dbColumn.Scale     = column.Scale;
         }
         projectContext.SaveChanges();
     }
 }
        //public ColumnValueRangeDTO GetColumnValueRange(column)
        //{
        //    ColumnDTO result = new ColumnDTO();
        //    using (var projectContext = new DataAccess.MyProjectEntities())
        //    {
        //        var column = projectContext.ColumnValueRange.First(x => x.ID == id);
        //        return ToColumnValueRangeDTO(column);
        //    }
        //}

        public void RemoveColumnValueRangeID(int columnID)
        {
            using (var projectContext = new DataAccess.MyProjectEntities())
            {
                var dbColumnValueRange = projectContext.ColumnValueRange.FirstOrDefault(x => x.ID == columnID);
                if (dbColumnValueRange != null)
                {
                    while (dbColumnValueRange.ColumnValueRangeDetails.Any())
                    {
                        projectContext.ColumnValueRangeDetails.Remove(dbColumnValueRange.ColumnValueRangeDetails.First());
                    }
                    projectContext.ColumnValueRange.Remove(dbColumnValueRange);
                    projectContext.SaveChanges();
                }
            }
        }
Exemple #29
0
        public int GetOrCreateEntityRelationshipTailID(int entityID, string path)
        {
            using (var projectContext = new DataAccess.MyProjectEntities())
            {
                //var dbEntityRelationshipTail = ToEntityRelationshipTail(entityID, targetEntityID, EntityRelationshipTail, "");
                //projectContext.EntityRelationshipTail.Add(dbEntityRelationshipTail);
                var dbItem = projectContext.EntityRelationshipTail.FirstOrDefault(x => x.TableDrivedEntityID == entityID && x.RelationshipPath == path);
                if (dbItem == null)
                {
                    dbItem = GetOrCreateEntityRelationshipTail(projectContext, entityID, path);

                    projectContext.SaveChanges();
                }
                return(dbItem.ID);
            }
        }
Exemple #30
0
 public void UpdateSubUnionToSuperUnionRelationships(List <SubUnionToSuperUnionRelationshipDTO> relationships)
 {
     using (var projectContext = new DataAccess.MyProjectEntities())
     {
         foreach (var relationship in relationships)
         {
             var dbRelationship = projectContext.SubUnionToUnionRelationshipType.First(x => x.ID == relationship.ID);
             dbRelationship.RelationshipType.IsOtherSideCreatable         = relationship.IsOtherSideCreatable;
             dbRelationship.RelationshipType.IsOtherSideDirectlyCreatable = relationship.IsOtherSideDirectlyCreatable;
             //dbRelationship.RelationshipType.IsOtherSideTransferable = relationship.IsOtherSideTransferable;
             dbRelationship.RelationshipType.Relationship.Name  = relationship.Name;
             dbRelationship.RelationshipType.Relationship.Alias = relationship.Alias;
         }
         projectContext.SaveChanges();
     }
 }