Пример #1
0
        // GET: Book/Edit/5
        public ActionResult Edit(int id)
        {
            User user = (User)Session["User"];

            var listCategories = _categoryRepository.GetByUser(user.IdUser);
            var listAccounts   = _accountRepository.GetByUser(user.IdUser);


            ViewBag.listCategories = new SelectList(listCategories, "IdCategory", "Description", "Selecione uma categoria");
            ViewBag.listAccounts   = new SelectList(listAccounts, "IdAccount", "Description", "Selecione uma conta");

            Book book = _bookRepository.GetById(id);

            book.IdAccountHidden    = book.IdAccount;
            book.RepeatPeriodHidden = book.RepeatPeriod;


            if (book.RepeatPeriod != Book.BookRepeatPeriod.NoRepeat)
            {
                book.Repeat = 1;
            }

            var parcels = _parcelRepository.GetByBook(book.IdBook);

            book.NParcels       = parcels.Count();
            book.NParcelsHidden = book.NParcels;
            book.isPay          = parcels.Where(c => c.PayDay != null).Count();

            return(View(book));
        }