Exemplo n.º 1
0
        public ActionResult AddBook(BookViewModel bookViewModel)
        {
            int         value = Convert.ToInt32(bookViewModel.AuthorName);
            TotalCounts count = new TotalCounts();

            if (ModelState.IsValid)
            {
                Books book = new Books();
                book.Name       = bookViewModel.Name;
                book.Authors.Id = authorRepository.GetById(value).Id;
                book.Isbn       = bookViewModel.Isbn;
                bookRepository.Add(book);

                long total = bookRepository.GetBooksCount();
                using (ITransaction transaction = UnitOfWork.OpenSession().BeginTransaction())
                {
                    total           += 1;
                    count.BooksCount = total;
                    transaction.Commit();
                }
                return(RedirectToAction("Index"));
            }
            var model = new BookViewModel()
            {
                Authors = GetAuthorsSelectList()
            };

            return(View(model));
        }
Exemplo n.º 2
0
        public ActionResult Delete(int id)
        {
            TotalCounts count = new TotalCounts();
            var         book  = bookRepository.GetById(id);

            bookRepository.SoftDelete(book);
            long total = bookRepository.GetBooksCount();

            total           -= 1;
            count.BooksCount = total;
            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
        private void editGroupsButton_Click(object sender, EventArgs e)
        {
            if (session != null)
            {
                var gcf = new GroupingControlForm(session.SessionFactory);

                if (gcf.ShowDialog() == DialogResult.OK)
                {
                    ClearData();
                    session.Clear();

                    //reload grouping
                    var rootGrouping = checkedGroupings.Count > 0 ? checkedGroupings.First() : null;
                    basicDataFilter = dataFilter;
                    basicTotalCounts = new TotalCounts(session, viewFilter);
                    rowsBySource = new Dictionary<DataFilterKey, List<Row>>();
                    basicRows = getChildren(rootGrouping, dataFilter);
                    basicRowsBySource = rowsBySource;

                    SetData(session, viewFilter);
                    //(this.ParentForm as IDPickerForm).ApplyBasicFilter();
                }
                //TODO- Find a better way of doing this
            }

        }
Exemplo n.º 4
0
        void setData(object sender, DoWorkEventArgs e)
        {
            try
            {
                var rootGrouping = checkedGroupings.FirstOrDefault();

                if (dataFilter.IsBasicFilter)
                {
                    if (basicDataFilter == null || (viewFilter.IsBasicFilter && dataFilter != basicDataFilter))
                    {
                        basicDataFilter = dataFilter;
                        basicTotalCounts = new TotalCounts(session, viewFilter);

                        rowsBySource = new Dictionary<DataFilterKey, List<Row>>();
                        basicRows = getChildren(rootGrouping, dataFilter);
                        basicRowsBySource = rowsBySource;
                    }

                    if(viewFilter.IsBasicFilter)
                        totalCounts = basicTotalCounts;
                    else
                        totalCounts = new TotalCounts(session, viewFilter);
                    rowsBySource = basicRowsBySource;
                    rows = basicRows;
                    unfilteredRows = null;
                }
                else
                {
                    totalCounts = new TotalCounts(session, viewFilter);
                    rowsBySource = new Dictionary<DataFilterKey, List<Row>>();
                    rows = getChildren(rootGrouping, dataFilter);
                    unfilteredRows = null;
                }

                applyFindFilter();
                applySort();

                OnFinishedSetData();
            }
            catch (Exception ex)
            {
                e.Result = ex;
            }
        }