Esempio n. 1
0
        public void create_mapper_property_for_nullable_int_column()
        {
            // Arrange
            IColumns columns = new CategoryColumns();

            columns.Add(new ViewCountIntNullableColumn());

            ITable table    = new CategoryTable(columns, null);
            string expected = "model.ViewCount = entity.ViewCount.HasValue ? (int)entity.ViewCount : default(int);";

            // Act
            string actual = string.Empty;

            foreach (IColumn c in table.Columns)
            {
                actual = "model." + c.Name + " = entity." + c.Name;
                if (c.LanguageType.ToLower() != "string")
                {
                    if (c.IsNullable)
                    {
                        actual += ".HasValue ? (" + c.LanguageType + ")entity." + c.Name + " : default(" + c.LanguageType + ")";
                    }
                }
                actual += ";";
            }

            // Assert
            Assert.AreEqual(expected, actual);
        }
Esempio n. 2
0
        public void create_mapper_property_for_nullable_datetime_column()
        {
            // Arrange
            IColumns columns = new CategoryColumns();

            columns.Add(new DateTimeNullableColumn());

            ITable table    = new CategoryTable(columns, null);
            string expected = "model.DateCreated = entity.DateCreated.HasValue ? (DateTime)entity.DateCreated : default(DateTime)";

            // Act
            string actual = string.Empty;

            foreach (IColumn c in table.Columns)
            {
                if (c.LanguageType.ToLower() != "string")
                {
                    if (c.IsNullable)
                    {
                        actual = "model." + c.Name + " = entity." + c.Name + ".HasValue ? (DateTime)entity.DateCreated : default(DateTime)";
                    }
                }
            }

            // Assert
            Assert.AreEqual(expected, actual);
        }
Esempio n. 3
0
        private void btadd_Click(object sender, EventArgs e)
        {
            int oritotalrow = gvcategories.Rows.Count;

            var form = new ManageCategories();

            form.userdata = userdata;
            form.ShowDialog();
            LoadData();

            int newtotalrow = gvcategories.Rows.Count;

            if (oritotalrow != newtotalrow)
            {
                var newCats = new CategoryColumns();
                newCats = categoryRepository.GetByAny(1);
                int newId = newCats.catid;

                foreach (DataGridViewRow row in gvcategories.Rows)
                {
                    if (((int)row.Cells["id"].Value) == newId)
                    {
                        gvcategories.Rows[row.Index].Selected = true;
                        break;
                    }
                }
            }
        }
Esempio n. 4
0
        public void loop_through_all_columns_in_CategoryTable()
        {
            // Arrange
            IColumns columns = new CategoryColumns();
            ITable   table   = new CategoryTable(columns, null);

            // Act
            foreach (IColumn column in table.Columns)
            {
                Console.WriteLine(column.Name + " - Type: " + column.LanguageType + " - IsPrimaryKey: " + column.IsInPrimaryKey + " - IsNullable: " + column.IsNullable);
            }
        }
Esempio n. 5
0
        public void categoryname_column_in_table()
        {
            // Arrange
            IColumns columns = new CategoryColumns();
            ITable   table   = new CategoryTable(columns, null);

            // Act
            IColumn categoryColumn = (CategoryNameColumn)table.Columns[1];
            string  name           = categoryColumn.Name;

            // Assert
            Assert.AreEqual("CategoryName", name);
        }
        public void categoryname_column_in_table()
        {
            // Arrange
            IColumns columns = new CategoryColumns();
            ITable table = new CategoryTable(columns, null);

            // Act
            IColumn categoryColumn = (CategoryNameColumn)table.Columns[1];
            string name = categoryColumn.Name;

            // Assert
            Assert.AreEqual("CategoryName", name);
        }
Esempio n. 7
0
        public void display_output_using_output_dot_text()
        {
            // Arrange
            IColumns columns = new CategoryColumns();
            ITable   table   = new CategoryTable(columns, null);

            // Act
            foreach (IColumn column in table.Columns)
            {
                Console.WriteLine(column.Name + " - Type: " + column.LanguageType + " - IsPrimaryKey: " + column.IsInPrimaryKey + " - IsNullable: " + column.IsNullable);
            }

            // Assert
        }
Esempio n. 8
0
        public void create_complete_mapper_for_category_table_with_nullable_datetime_column()
        {
            // Arrange
            IColumns columns = new CategoryColumns();

            columns.Add(new DateTimeNullableColumn());

            ITable table    = new CategoryTable(columns, null);
            string expected = "model.Id = (int)entity.Id;" + Environment.NewLine;

            expected += "model.CategoryName = entity.CategoryName;" + Environment.NewLine;
            expected += "model.rowversion = entity.Rowversion.AsBase64String();" + Environment.NewLine;
            expected += "model.DateCreated = entity.DateCreated.HasValue ? (DateTime)entity.DateCreated : default(DateTime);" + Environment.NewLine;

            // Act
            string actual = string.Empty;

            foreach (IColumn c in table.Columns)
            {
                if (c.IsInPrimaryKey)
                {
                    actual += "model." + c.Name + " = (int)entity." + c.Name + ";" + Environment.NewLine;
                }
                else if (c.Name.ToLower() == "rowversion")
                {
                    actual += "model." + c.Name.ToLower() + " = entity." + c.Name + ".AsBase64String();" + Environment.NewLine;
                }
                else
                {
                    actual += "model." + c.Name + " = entity." + c.Name;
                    if (c.LanguageType.ToLower() != "string")
                    {
                        if (c.IsNullable)
                        {
                            actual += ".HasValue ? (" + c.LanguageType + ")entity." + c.Name + " : default(" + c.LanguageType + ")";
                        }
                    }
                    actual += ";" + Environment.NewLine;
                }
            }

            // Assert
            Assert.AreEqual(expected, actual);
        }
        public void create_complete_mapper_for_category_table()
        {
            // Arrange
            IColumns columns = new CategoryColumns();
            columns.Add(new DateTimeColumn());

            ITable table = new CategoryTable(columns, null);
            string expected = "model.Id = (int)entity.Id;" + Environment.NewLine;
            expected += "model.CategoryName = entity.CategoryName;" + Environment.NewLine;
            expected += "model.rowversion = entity.Rowversion.AsBase64String();" + Environment.NewLine;
            expected += "model.DateCreated = entity.DateCreated;" + Environment.NewLine;

            // Act
            string actual = string.Empty;
            foreach (IColumn c in table.Columns)
            {
                if (c.IsInPrimaryKey)
                {
                    actual += "model." + c.Name + " = (int)entity." + c.Name + ";" + Environment.NewLine;
                }
                else if (c.Name.ToLower() == "rowversion")
                {
                    actual += "model." + c.Name.ToLower() + " = entity." + c.Name + ".AsBase64String();" + Environment.NewLine;
                }
                else
                {
                    actual += "model." + c.Name + " = entity." + c.Name;
                    if (c.LanguageType.ToLower() != "string")
                    {
                        if (c.IsNullable)
                        {
                            actual += ".HasValue ? (" + c.LanguageType + ")entity." + c.Name + " : default(" + c.LanguageType + ")";
                        }
                    }
                    actual += ";" + Environment.NewLine;
                }
            }

            // Assert
            Assert.AreEqual(expected, actual);
        }
Esempio n. 10
0
        public void create_mapper_property_for_rowversion_column()
        {
            // Arrange
            IColumns columns  = new CategoryColumns();
            ITable   table    = new CategoryTable(columns, null);
            string   expected = "model.rowversion = entity.Rowversion.AsBase64String();";

            // Act
            string actual = string.Empty;

            foreach (IColumn c in table.Columns)
            {
                if (c.Name.ToLower() == "rowversion")
                {
                    actual = "model." + c.Name.ToLower() + " = entity." + c.Name + ".AsBase64String();";
                }
            }

            // Assert
            Assert.AreEqual(expected, actual);
        }
Esempio n. 11
0
        public void dataannotationswriter_test()
        {
            // Arrange
            IColumns columns = new CategoryColumns();
            columns.Add(new IdentityColumn());
            columns.Add(new DateTimeColumn());
            columns.Add(new CategoryNameColumn());
            columns.Add(new RowversionColumn());

            ITable table = new CategoryTable(columns, null);

            RequestContext context = new RequestContext();
            context.Zeus = new TempZeusContext();

            // Act
            ICodeWriter writer = new DataAnnotationsWriter(context, table);
            writer.Write();
            string actual = writer.Read;

            Console.WriteLine(actual);
        }
Esempio n. 12
0
        public void create_mapper_property_mapping_for_identity_column()
        {
            // Arrange
            IColumns columns  = new CategoryColumns();
            ITable   table    = new CategoryTable(columns, null);
            string   expected = "model.Id = (int)entity.Id;";

            // Act
            string actual = string.Empty;

            foreach (IColumn c in table.Columns)
            {
                if (c.IsInPrimaryKey)
                {
                    actual = "model." + c.Name + " = (int)entity." + c.Name + ";";
                }
            }

            // Assert
            Assert.AreEqual(expected, actual);
        }
Esempio n. 13
0
        public void create_mapper_property_for_string_column()
        {
            // Arrange
            IColumns columns  = new CategoryColumns();
            ITable   table    = new CategoryTable(columns, null);
            string   expected = "model.CategoryName = entity.CategoryName";

            // Act
            string actual = string.Empty;

            foreach (IColumn c in table.Columns)
            {
                if (c.LanguageType == "string")
                {
                    actual = "model." + c.Name + " = entity." + c.Name;
                }
            }

            // Assert
            Assert.AreEqual(expected, actual);
        }
Esempio n. 14
0
        public void TestMethod1()
        {
            // Arrange
            ITable table = null;
            IColumns columns = new CategoryColumns();
            columns.Add(new IdentityColumn(table));
            columns.Add(new DateTimeColumn(table));
            columns.Add(new CategoryNameColumn(table));

            table = new CategoryTable(columns, null);

            RequestContext context = new RequestContext();
            context.Zeus = new TempZeusContext();
            //context.ScriptSettings = new ScriptSettings(null, null, null, null);

            Condor.Core.Property prop = null;
            foreach (IColumn c in table.Columns)
            {
                prop = new BusinessObjectsPropertyRenderDataAnnotationsForDbContext(c, context);
                prop.Render();
            }
        }
Esempio n. 15
0
        public void TestMethod1()
        {
            // Arrange
            ITable   table   = null;
            IColumns columns = new CategoryColumns();

            columns.Add(new IdentityColumn(table));
            columns.Add(new DateTimeColumn(table));
            columns.Add(new CategoryNameColumn(table));

            table = new CategoryTable(columns, null);

            RequestContext context = new RequestContext();

            context.Zeus = new TempZeusContext();
            //context.ScriptSettings = new ScriptSettings(null, null, null, null);

            Condor.Core.Property prop = null;
            foreach (IColumn c in table.Columns)
            {
                prop = new BusinessObjectsPropertyRenderDataAnnotationsForDbContext(c, context);
                prop.Render();
            }
        }
Esempio n. 16
0
        public void dataannotationswriter_test()
        {
            // Arrange
            IColumns columns = new CategoryColumns();

            columns.Add(new IdentityColumn());
            columns.Add(new DateTimeColumn());
            columns.Add(new CategoryNameColumn());
            columns.Add(new RowversionColumn());

            ITable table = new CategoryTable(columns, null);

            RequestContext context = new RequestContext();

            context.Zeus = new TempZeusContext();

            // Act
            ICodeWriter writer = new DataAnnotationsWriter(context, table);

            writer.Write();
            string actual = writer.Read;

            Console.WriteLine(actual);
        }
Esempio n. 17
0
        public void create_mapper_property_for_rowversion_column()
        {
            // Arrange
            IColumns columns = new CategoryColumns();
            ITable table = new CategoryTable(columns, null);
            string expected = "model.rowversion = entity.Rowversion.AsBase64String();";

            // Act
            string actual = string.Empty;
            foreach (IColumn c in table.Columns)
            {
                if (c.Name.ToLower() == "rowversion")
                {
                    actual = "model." + c.Name.ToLower() + " = entity." + c.Name + ".AsBase64String();";
                }
            }

            // Assert
            Assert.AreEqual(expected, actual);
        }
Esempio n. 18
0
        public void create_mapper_property_for_nullable_int_column()
        {
            // Arrange
            IColumns columns = new CategoryColumns();
            columns.Add(new ViewCountIntNullableColumn());

            ITable table = new CategoryTable(columns, null);
            string expected = "model.ViewCount = entity.ViewCount.HasValue ? (int)entity.ViewCount : default(int);";

            // Act
            string actual = string.Empty;
            foreach (IColumn c in table.Columns)
            {
                actual = "model." + c.Name + " = entity." + c.Name;
                if (c.LanguageType.ToLower() != "string")
                {
                    if (c.IsNullable)
                    {
                        actual += ".HasValue ? (" + c.LanguageType + ")entity." + c.Name + " : default(" + c.LanguageType + ")";
                    }
                }
                actual += ";";
            }

            // Assert
            Assert.AreEqual(expected, actual);
        }
Esempio n. 19
0
        public void create_mapper_property_for_nullable_datetime_column()
        {
            // Arrange
            IColumns columns = new CategoryColumns();
            columns.Add(new DateTimeNullableColumn());

            ITable table = new CategoryTable(columns, null);
            string expected = "model.DateCreated = entity.DateCreated.HasValue ? (DateTime)entity.DateCreated : default(DateTime)";

            // Act
            string actual = string.Empty;
            foreach (IColumn c in table.Columns)
            {
                if (c.LanguageType.ToLower() != "string")
                {
                    if (c.IsNullable)
                    {
                        actual = "model." + c.Name + " = entity." + c.Name + ".HasValue ? (DateTime)entity.DateCreated : default(DateTime)";
                    }
                }
            }

            // Assert
            Assert.AreEqual(expected, actual);
        }
Esempio n. 20
0
        private void btsave_Click(object sender, EventArgs e)
        {
            ListCategory = categoryRepo.GetAll();
            int samename = 0;

            if (Editmode)
            {
                foreach (var existingdetails in ListCategory)
                {
                    if (existingdetails.name == tbcatname.Text && existingdetails.catid != CategoryData.catid)
                    {
                        samename += 1;
                        break;
                    }
                }


                if (tbcatname.Text == "")
                {
                    MessageBox.Show("Yang bertanda Bintang tidak boleh kosong");
                }
                else if (samename > 0)
                {
                    MessageBox.Show("Nama yang anda masukkan sudah terdaftar");
                    samename = 0;
                }
                else
                {
                    var CatDataBefore = new CategoryColumns();
                    CatDataBefore.name   = CategoryData.name;
                    CatDataBefore.remark = CategoryData.remark;

                    CategoryData.name       = tbcatname.Text;
                    CategoryData.remark     = tbremark.Text;
                    CategoryData.updated_by = userdata.username;

                    bool havechanges = false;

                    if (CatDataBefore.name == CategoryData.name && CatDataBefore.remark == CategoryData.remark)
                    {
                        havechanges = true;
                    }


                    if (havechanges)
                    {
                        MessageBox.Show("Tidak ada data yang anda ubah");
                        CategoryData.name   = CatDataBefore.name;
                        CategoryData.remark = CatDataBefore.remark;
                    }
                    else if (categoryRepo.Update(CategoryData))
                    {
                        MessageBox.Show("Data telah berhasil di ubah");
                        Close();
                    }
                    else
                    {
                        MessageBox.Show("Data gagal di ubah");
                        CategoryData.name   = CatDataBefore.name;
                        CategoryData.remark = CatDataBefore.remark;
                    }
                }
            }
            else
            {
                foreach (var existingdetails in ListCategory)
                {
                    if (existingdetails.name == tbcatname.Text)
                    {
                        samename += 1;
                        break;
                    }
                }

                if (tbcatname.Text == "")
                {
                    MessageBox.Show(" Yang bertanda Bintang tidak boleh kosong");
                }
                else if (samename > 0)
                {
                    MessageBox.Show("Nama yang anda masukkan sudah terdaftar");
                    samename = 0;
                }
                else
                {
                    var cats = new CategoryColumns();

                    cats.name       = tbcatname.Text;
                    cats.remark     = tbremark.Text;
                    cats.created_by = userdata.username;


                    if (categoryRepo.Add(cats))
                    {
                        MessageBox.Show("Data baru telah berhasil di tambahkan");
                        Close();
                    }
                    else
                    {
                        MessageBox.Show("Data baru gagal ditambahkan");
                    }
                }
            }
        }
Esempio n. 21
0
        public void create_mapper_property_for_string_column()
        {
            // Arrange
            IColumns columns = new CategoryColumns();
            ITable table = new CategoryTable(columns, null);
            string expected = "model.CategoryName = entity.CategoryName";

            // Act
            string actual = string.Empty;
            foreach (IColumn c in table.Columns)
            {
                if (c.LanguageType == "string")
                {
                    actual = "model." + c.Name + " = entity." + c.Name;
                }
            }

            // Assert
            Assert.AreEqual(expected, actual);
        }
Esempio n. 22
0
        public void create_mapper_property_mapping_for_identity_column()
        {
            // Arrange
            IColumns columns = new CategoryColumns();
            ITable table = new CategoryTable(columns, null);
            string expected = "model.Id = (int)entity.Id;";

            // Act
            string actual = string.Empty;
            foreach (IColumn c in table.Columns)
            {
                if (c.IsInPrimaryKey)
                {
                    actual = "model." + c.Name + " = (int)entity." + c.Name + ";";
                }
            }

            // Assert
            Assert.AreEqual(expected, actual);
        }
Esempio n. 23
0
        public void loop_through_all_columns_in_CategoryTable()
        {
            // Arrange
            IColumns columns = new CategoryColumns();
            ITable table = new CategoryTable(columns, null);

            // Act
            foreach (IColumn column in table.Columns)
            {
                Console.WriteLine(column.Name + " - Type: " + column.LanguageType + " - IsPrimaryKey: " + column.IsInPrimaryKey + " - IsNullable: " + column.IsNullable);
            }
        }
Esempio n. 24
0
        public void display_output_using_output_dot_text()
        {
            // Arrange
            IColumns columns = new CategoryColumns();
            ITable table = new CategoryTable(columns, null);

            // Act
            foreach (IColumn column in table.Columns)
            {
                Console.WriteLine(column.Name + " - Type: " + column.LanguageType + " - IsPrimaryKey: " + column.IsInPrimaryKey + " - IsNullable: " + column.IsNullable);
            }

            // Assert
        }