예제 #1
0
        // The return type can be changed to IEnumerable, however to support
        // paging and sorting, the following parameters must be added:
        //     int maximumRows
        //     int startRowIndex
        //     out int totalRowCount
        //     string sortByExpression
        public IQueryable <Category> CategoriesList_GetData()
        {
            var context = new TODOListEntities();

            var categories =
                context.Categories;

            return(categories);
        }
예제 #2
0
        // The return type can be changed to IEnumerable, however to support
        // paging and sorting, the following parameters must be added:
        //     int maximumRows
        //     int startRowIndex
        //     out int totalRowCount
        //     string sortByExpression
        public IQueryable<Category> CategoriesList_GetData()
        {
            var context = new TODOListEntities();

            var categories =
                context.Categories;

            return categories;

        }
예제 #3
0
        // The id parameter name should match the DataKeyNames value set on the control
        public void TodosListView_DeleteItem(int id)
        {
            var context = new TODOListEntities();

            using (context)
            {
                var todo = context.Todos.FirstOrDefault(t => t.Id == id);
                context.Todos.Remove(todo);
                context.SaveChanges();
            }
        }
예제 #4
0
        // The id parameter name should match the DataKeyNames value set on the control
        public void CategoriesList_DeleteItem(int id)
        {
            var context = new TODOListEntities();
            using (context)
            {
                Category category = context.Categories.FirstOrDefault(c => c.Id == id);

                context.Categories.Remove(category);

                context.SaveChanges();
            }
        }
예제 #5
0
        // The id parameter name should match the DataKeyNames value set on the control
        public void CategoriesList_DeleteItem(int id)
        {
            var context = new TODOListEntities();

            using (context)
            {
                Category category = context.Categories.FirstOrDefault(c => c.Id == id);

                context.Categories.Remove(category);

                context.SaveChanges();
            }
        }
예제 #6
0
        public IQueryable <Todo> TodosListView_GetData()
        {
            var context = new TODOListEntities();

            if (this.CategoriesList.SelectedDataKey != null)
            {
                int id = int.Parse(this.CategoriesList.SelectedDataKey.Value.ToString());

                return(context.Categories.FirstOrDefault(x => x.Id == id).Todos.AsQueryable());
            }
            else
            {
                return(null);
            }
        }
예제 #7
0
        public void CategoriesList_InsertItem()
        {
            var item = new Todo().Category;

            TryUpdateModel(item);
            if (ModelState.IsValid)
            {
                var context = new TODOListEntities();
                using (context)
                {
                    context.Categories.Add(item);

                    context.SaveChanges();
                }
            }
        }
예제 #8
0
        public void CategoriesList_InsertItem()
        {
            var item = new Todo().Category;
            TryUpdateModel(item);
            if (ModelState.IsValid)
            {
                var context = new TODOListEntities();
                using (context)
                {
                    context.Categories.Add(item);

                    context.SaveChanges();
                }

            }
        }
예제 #9
0
        public void TodosListView_InsertItem()
        {
            var item = new Todo();

            TryUpdateModel(item);
            if (ModelState.IsValid)
            {
                item.DateOfLastChange = DateTime.Now;

                var context = new TODOListEntities();
                using (context)
                {
                    context.Todos.Add(item);
                    context.SaveChanges();
                }
            }
        }
예제 #10
0
        // The id parameter name should match the DataKeyNames value set on the control
        public void CategoriesList_UpdateItem(int id)
        {
            var context = new TODOListEntities();

            using (context)
            {
                Category category = context.Categories.Find(id);
                if (category == null)
                {
                    // The item wasn't found
                    ModelState.AddModelError("",
                                             String.Format("Product with id {0} was not found", id));
                    return;
                }
                TryUpdateModel(category);
                if (ModelState.IsValid)
                {
                    context.Entry(category).State = EntityState.Modified;
                    context.SaveChanges();
                }
            }
        }
예제 #11
0
        // The id parameter name should match the DataKeyNames value set on the control
        public void TodosListView_UpdateItem(int id)
        {
            var context = new TODOListEntities();

            using (context)
            {
                Todo todo = context.Todos.Find(id);
                if (todo == null)
                {
                    // The item wasn't found
                    ModelState.AddModelError("",
                                             String.Format("Product with id {0} was not found", id));
                    return;
                }
                TryUpdateModel(todo);
                if (ModelState.IsValid)
                {
                    todo.DateOfLastChange     = DateTime.Now;
                    context.Entry(todo).State = EntityState.Modified;
                    context.SaveChanges();
                }
            }
        }
예제 #12
0
        // The id parameter name should match the DataKeyNames value set on the control
        public void CategoriesList_UpdateItem(int id)
        {

            var context = new TODOListEntities();

            using (context)
            {
                Category category = context.Categories.Find(id);
                if (category == null)
                {
                    // The item wasn't found
                    ModelState.AddModelError("",
                        String.Format("Product with id {0} was not found", id));
                    return;
                }
                TryUpdateModel(category);
                if (ModelState.IsValid)
                {
                    context.Entry(category).State = EntityState.Modified;
                    context.SaveChanges();
                }
            }
        }
예제 #13
0
        // The id parameter name should match the DataKeyNames value set on the control
        public void TodosListView_DeleteItem(int id)
        {
            var context = new TODOListEntities();

            using (context)
            {
                var todo = context.Todos.FirstOrDefault(t => t.Id == id);
                context.Todos.Remove(todo);
                context.SaveChanges();
            }
        }
예제 #14
0
        public void TodosListView_InsertItem()
        {
            var item = new Todo();
            TryUpdateModel(item);
            if (ModelState.IsValid)
            {
                item.DateOfLastChange = DateTime.Now;

                var context = new TODOListEntities();
                using (context)
                {
                    context.Todos.Add(item);
                    context.SaveChanges();
                }

            }
        }
예제 #15
0
        // The id parameter name should match the DataKeyNames value set on the control
        public void TodosListView_UpdateItem(int id)
        {
            var context = new TODOListEntities();

            using (context)
            {
                Todo todo = context.Todos.Find(id);
                if (todo == null)
                {
                    // The item wasn't found
                    ModelState.AddModelError("",
                        String.Format("Product with id {0} was not found", id));
                    return;
                }
                TryUpdateModel(todo);
                if (ModelState.IsValid)
                {
                    todo.DateOfLastChange = DateTime.Now;
                    context.Entry(todo).State = EntityState.Modified;
                    context.SaveChanges();
                }
            }
        }
예제 #16
0
        public IQueryable<Todo> TodosListView_GetData()
        {
            var context = new TODOListEntities();

            if (this.CategoriesList.SelectedDataKey != null)
            {
                int id = int.Parse(this.CategoriesList.SelectedDataKey.Value.ToString());

                return context.Categories.FirstOrDefault(x => x.Id == id).Todos.AsQueryable();
            }
            else
            {
                return null;
            }

        }