Exemplo n.º 1
0
        public ActionResult AddStudentToCategory(CategoryModel model)
        {
            CategoryTable c = new CategoryTable();

            Session["CategoryID"] = model.CategoryID;
            return(RedirectToAction("Create", "Home", new { area = "" }));
        }
Exemplo n.º 2
0
        private ITablesProvider InitMockedDb()
        {
            CategoryTable categoryTable = new CategoryTable();
            CurrencyTable currencyTable = new CurrencyTable();

            PersonTable personTable = new PersonTable();

            BidTable          bidTable          = new BidTable();
            PersonBidderTable personBidderTable = new PersonBidderTable(bidTable);

            AuctionsTable auctionsTable = new AuctionsTable();
            ProductTable  productTable  = new ProductTable();

            PersonMarkTable    personMarkTable    = new PersonMarkTable();
            PersonOfferorTable personOfferorTable = new PersonOfferorTable();


            Mock <ITablesProvider> mock = new Mock <ITablesProvider>();

            mock.Setup(x => x.GetCategoryTable()).Returns(categoryTable);
            mock.Setup(x => x.GetCurrencyTable()).Returns(currencyTable);

            mock.Setup(x => x.GetPersonTable()).Returns(personTable);

            mock.Setup(x => x.GetBidTable()).Returns(bidTable);
            mock.Setup(x => x.GetPersonBidderTable()).Returns(personBidderTable);

            mock.Setup(x => x.GetAuctionTable()).Returns(auctionsTable);
            mock.Setup(x => x.GetProductTable()).Returns(productTable);

            mock.Setup(x => x.GetPersonMarkTable()).Returns(personMarkTable);
            mock.Setup(x => x.GetPersonOfferorTable()).Returns(personOfferorTable);

            return(mock.Object);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
        public CategoriesUpdaterTests()
        {
            CategoryTable          categoryTable = new CategoryTable();
            Mock <ITablesProvider> mock          = new Mock <ITablesProvider>();

            mock.Setup(x => x.GetCategoryTable()).Returns(categoryTable);

            tables = mock.Object;
        }
        private void BtnAddCategory_OnClick(object sender, RoutedEventArgs e)
        {
            CategoryTable ct = new CategoryTable();

            ct.cat_id = int.Parse(CategoryIdBox.Text);
            ct.cat_nm = CategoryNameBox.Text;

            mt.AddNewCategory(ct);
        }
Exemplo n.º 7
0
        public HomeViewModel()
        {
            var loader = new CategoryTable();

            InitDirectory();
            LoadNumbers();
            LoadCategories(loader);
            TotalCount = loader.GetTotalCount() + " Questions in total";
        }
Exemplo n.º 8
0
 public ActionResult EditCategory(CategoryTable check)
 {
     if (ModelState.IsValid)
     {
         db.Entry(check).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Categories"));
     }
     return(View(check));
 }
Exemplo n.º 9
0
 protected override void Seed(DatabaseContext context)
 {
     SettingTable.Initialize(context);
     FileTypeTable.Initialize(context);
     LanguageTable.Initialize(context);
     CategoryTable.Initialize(context);
     UserMessageCreationModeTable.Initialize(context);
     UserMessageStateTable.Initialize(context);
     MessageStateTable.Initialize(context);
     CategoryFavouriteLevelTable.Initialize(context);
 }
 public MovementProfileController()
 {
     this._profileTable       = new ProfileTable("MovementProfiles");
     this._movementTable      = new MovementTable();
     this._userTeble          = new UserTable();
     this._authorizationTable = new AuthorizationTable();
     this._categoryTable      = new CategoryTable();
     validatepermissions      = new validatePermissions();
     this._processesTable     = new ProcessesTable();
     _logTable = new LogBook.Controllers.LogBookController();
 }
Exemplo n.º 11
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);
            }
        }
Exemplo n.º 12
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        CategoryTable ct = new CategoryTable();

        ct.CName = TextBox1.Text;

        c.da.CategoryTables.InsertOnSubmit(ct);
        c.da.SubmitChanges();
        Response.Write("<script>alert('Category added Successfull...!')</script>");
        TextBox1.Text = "";
        bind();
    }
Exemplo n.º 13
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);
        }
Exemplo n.º 14
0
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        CategoryTable ct = new CategoryTable();

        ct.CatName = TextBox1.Text;
        FileUpload1.SaveAs(Server.MapPath("~/Dashboard/CatPic/" + FileUpload1.FileName));
        ct.Pic = "/Dashboard/CatPic/" + FileUpload1.FileName;
        dl.da.CategoryTables.InsertOnSubmit(ct);
        dl.da.SubmitChanges();
        Response.Write("<script>alert('Success')</script>");
        TextBox1.Text = "";
        bind();
    }
Exemplo n.º 15
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
        }
Exemplo n.º 16
0
 void ReleaseDesignerOutlets()
 {
     if (CategoryTable != null)
     {
         CategoryTable.Dispose();
         CategoryTable = null;
     }
     if (CoursesTabBarItem != null)
     {
         CoursesTabBarItem.Dispose();
         CoursesTabBarItem = null;
     }
     if (ProfileTabBarItem != null)
     {
         ProfileTabBarItem.Dispose();
         ProfileTabBarItem = null;
     }
     if (SearchBar != null)
     {
         SearchBar.Dispose();
         SearchBar = null;
     }
     if (SearchResultsTable != null)
     {
         SearchResultsTable.Dispose();
         SearchResultsTable = null;
     }
     if (TabBar != null)
     {
         TabBar.Dispose();
         TabBar = null;
     }
     if (TvNoCoursesFound != null)
     {
         TvNoCoursesFound.Dispose();
         TvNoCoursesFound = null;
     }
     if (TvSearchFaulted != null)
     {
         TvSearchFaulted.Dispose();
         TvSearchFaulted = null;
     }
     if (TvSearching != null)
     {
         TvSearching.Dispose();
         TvSearching = null;
     }
 }
Exemplo n.º 17
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);
        }
Exemplo n.º 18
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);
        }
Exemplo n.º 19
0
        //public decimal CalculateAccountBalance(int accountNo)
        //{
        //    string sql = string.Format(@"
        //        select
        //            Accounts.BalanceBroughtForwardAmount +
        //         (
        //          select isnull(SUM(Amount), 0)
        //          from
        //                    AccountTransactions
        //                where AccountNo = {0}
        //         ) as BalanceAmount
        //        from Accounts
        //        where No = {0}", accountNo);

        //    return decimal.Parse(Connection.GetScalar(sql).ToString());
        //}

        public CategoryCollection GetSubCategories()
        {
            string sql = @"
                select *
                from Categories c1
                where
                    IsArchived <> 1 and
                    (
                        select count(*)
                        from Categories c2
                        where c2.ParentCategoryNo = c1.No
                    ) = 0
                order by
                    Type desc,
                    Name asc";

            CategoryTable categoryTable = new CategoryTable();

            Connection.GetTable(categoryTable, sql);
            return(CategoryCollection.CreateCategoryCollection(categoryTable));
        }
Exemplo n.º 20
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);
        }
Exemplo n.º 21
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);
        }
Exemplo n.º 22
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();
            }
        }
Exemplo n.º 23
0
        public ActionResult AddCategory(CategoryModel obj)
        {
            int           fid        = (int)Session["FacultyID"];
            List <object> Parameters = new List <object>();

            obj.FacultyID = fid;

            Parameters.Add(obj.CategoryName);
            Parameters.Add(obj.FacultyID);
            //string CName = obj.CategoryName;
            object[] objectarray = Parameters.ToArray();

            var           context1 = new MailProEntities();
            CategoryTable c1       = new CategoryTable();
            var           s1       = obj.CategoryName;

            c1 = context1.CategoryTable.SingleOrDefault(x => x.CategoryName == s1 && x.FacultyID == fid);
            if (c1 != null)
            {
                ModelState.AddModelError("", "Category Already Exists");
                return(View());
            }
            else
            {
                int           output = Db.Database.ExecuteSqlCommand("insert into CategoryTable(CategoryName,FacultyID) values(@p0,@p1)", objectarray);
                CategoryTable c      = new CategoryTable();
                using (var context = new MailProEntities())
                {
                    var s = obj.CategoryName;

                    c = context.CategoryTable.SingleOrDefault(x => x.CategoryName == s);
                    Session["CategoryID"] = c.CategoryID;
                }
                ViewBag.MSG = "Category Added";
            }


            return(View());
        }
Exemplo n.º 24
0
 public ObservableCollection <CategoryTable> GetCategory()
 {
     try
     {
         ObservableCollection <CategoryTable> categories = new ObservableCollection <CategoryTable>();
         SQLQueryModel queryBuilder  = new SQLQueryModel();
         string        query         = string.Format("SELECT categoryID, categoryName FROM category");
         DataTable     categoryTable = new DataTable();
         categoryTable = queryBuilder.ExecuteMySQLQuery(query);
         foreach (DataRow row in categoryTable.Rows)
         {
             _categoryTable              = new CategoryTable();
             _categoryTable.CategoryID   = Convert.ToInt32(row["categoryID"]);
             _categoryTable.CategoryName = row["categoryName"].ToString();
             categories.Add(_categoryTable);
         }
         return(categories);
     }
     catch (ArgumentNullException nullex)
     {
         Protocol.WriteToProtocol(0, "GetCategory() :" + nullex.Message + nullex.StackTrace, "Category null Error");
         return(null);
     }
 }
Exemplo n.º 25
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);
        }
Exemplo n.º 26
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();
            }
        }
Exemplo n.º 27
0
 public CategoryController()
 {
     categoryTable = new CategoryTable();
 }
 CreateCategoryAsync(CategoryTable objCategoryTable)
 {
     _context.CategoryTable.Add(objCategoryTable);
     _context.SaveChanges();
     return(Task.FromResult(objCategoryTable));
 }
Exemplo n.º 29
0
 private void LoadCategories(CategoryTable loader)
 {
     CategoryList = CategoryTable.GetAllCategories();
     CategoryList.Insert(0, new Category(0, "All"));
 }
Exemplo n.º 30
0
        //Adding Categories through Model from Home Page


        public ActionResult Categoriespost(CategoryTable catadd)
        {
            db.CategoryTables.Add(catadd);
            db.SaveChanges();
            return(RedirectToAction("Categories", "Home"));
        }
Exemplo n.º 31
0
 /// Common Variables
 ///
 public CategoryViewModel() : base(nameof(CategoryViewModel))
 {
     Categories = new ObservableCollection <Category>(CategoryTable.GetAll());
 }