Exemplo n.º 1
0
 public void AddApplicationTableField(ApplicationTableField applicationTableField)
 {
     applicationTableField.LastModified = DateTime.UtcNow;
     applicationTableField.LastModifiedBy = "System";
     applicationTableField.RecordAdded = DateTime.UtcNow;
     applicationTableField.RecordAddedBy = "System";
     applicationTableField.IsDeleted = false;
     context.ApplicationTableFields.Add(applicationTableField);
     context.SaveChanges();
 }
Exemplo n.º 2
0
        private List<ViewModels.ApplicationTableAndFieldsViewModel> PopulateList(string Mode)
        {
            List<ViewModels.ApplicationTableAndFieldsViewModel> RetValue = new List<ViewModels.ApplicationTableAndFieldsViewModel>();
            var query = from p in context.ApplicationTables select p;

            if (Mode == "Active")
            {
                query = from p in context.ApplicationTables
                            where p.IsDeleted == false
                            orderby p.Description
                            select p;

            }
            else if (Mode =="All")
            {
                query = from p in context.ApplicationTables
                            orderby p.Description
                            select p;

            }
            else
            {
                query = from p in context.ApplicationTables
                            where p.IsDeleted == true
                            orderby p.Description
                            select p;

            }
            foreach (var item in query)
            {
                ViewModels.ApplicationTableAndFieldsViewModel m = new ViewModels.ApplicationTableAndFieldsViewModel();

                m.ParentTableID = item.ApplicationTableID;
                m.Description = item.Description;
                m.ApplicationTableFields = new List<ApplicationTableField>();

                var query2 = from c in context.ApplicationTableFields
                             where c.ApplicationTableID == m.ParentTableID && c.IsDeleted == false
                             orderby c.Description
                             select c;

                foreach (var c_item in query2)
                {
                    ApplicationTableField ct = new ApplicationTableField();
                    ct.ApplicationTableFieldID = c_item.ApplicationTableFieldID;
                    ct.Description = c_item.Description;
                    ct.ApplicationTableID = c_item.ApplicationTableID;
                    ct.FieldType = c_item.FieldType;
                    ct.IsAudited = c_item.IsAudited;
                    ct.LastModified = c_item.LastModified;
                    ct.LastModifiedBy = c_item.LastModifiedBy;
                    ct.RecordAdded = c_item.RecordAdded;
                    ct.RecordAddedBy = c_item.RecordAddedBy;
                    m.ApplicationTableFields.Add(ct);
                }
                RetValue.Add(m);
            }
            return RetValue;
        }