Beispiel #1
0
        // GET: Stock/Delete/5
        public ActionResult Delete(int id)
        {
            var stock = _unitOfWork.Stocks.Get(id);
            var model = new StockViewModel()
            {
                Id = stock.Id,
                InventoryKey = stock.InventoryKey,
                IsAvailable = stock.IsAvailable
            };

            return PartialView("_DeletePartial", model);
        }
Beispiel #2
0
        public ActionResult Create(StockViewModel model)
        {
            try
            {
                var book = _unitOfWork.Books.Get(model.BookId);
                var stock = new Stock() {Book = book, InventoryKey = model.InventoryKey, IsAvailable = true};

                book.Stocks.Add(stock);

                _unitOfWork.SaveChanges();

                return RedirectToAction("Index", "Book");
            }
            catch
            {
                return PartialView("_CreatePartial");
            }
        }
Beispiel #3
0
        public ActionResult Delete(int id, StockViewModel model)
        {
            try
            {
                var existingRecord = _unitOfWork.Stocks.Get(id);
                var book = existingRecord.Book;

                book.Stocks.Remove(existingRecord);

                _unitOfWork.Stocks.Delete(existingRecord);

                _unitOfWork.SaveChanges();

                return RedirectToAction("Index", new {id = book.Id});
            }
            catch
            {
                return PartialView("_DeletePartial");
            }
        }
Beispiel #4
0
        // GET: Stock/Create
        public ActionResult Create(int id)
        {
            var model = new StockViewModel {BookId = id};

            return PartialView("_CreatePartial", model);
        }