Ejemplo n.º 1
0
 public ActionResult AddBooks(long id)
 {
     AddDetailBookModel addBooksModel = new AddDetailBookModel();
     BookInfo bookInfo = this.IBookInfoDataProvider.GetBookInfoByID(id);
     addBooksModel.BookID = id;
     addBooksModel.BookName = bookInfo.BookName;
     addBooksModel.ISBN = bookInfo.ISBN;
     addBooksModel.BookStatusList = EnumHelper.GetEnumIEnumerable<BookStatus>(BookStatus.InStore);
     addBooksModel.BookStatusSelected = BookStatus.InStore;
     return View(addBooksModel);
 }
Ejemplo n.º 2
0
        public ActionResult AddBooks(AddDetailBookModel books)
        {
            BookDetailInfo booksInfo = books.GetEntity();
            this.IBookDetailInfoDataProvider.Add(booksInfo);

            BookInfo book = booksInfo.BookInfo;
            book.Avaliable_Inventory = book.Avaliable_Inventory + 1;
            book.Max_Inventory = book.Max_Inventory + 1;

            this.IBookInfoDataProvider.Update(book);

            return RedirectToAction("DetailBook", new { @id = books.BookID });
        }
Ejemplo n.º 3
0
        private void EditBooksUpdateBook(BookDetailInfo books, AddDetailBookModel model)
        {
            BookInfo book = books.BookInfo;

            switch (model.BookStatusSelected)
            {
                case BookStatus.InStore:
                    if (model.BeforeStatus != BookStatus.InStore && model.BeforeStatus == BookStatus.Error)
                    {
                        book.Avaliable_Inventory = book.Avaliable_Inventory + 1;
                        book.Max_Inventory = book.Max_Inventory + 1;
                    }
                    else if (model.BeforeStatus != BookStatus.InStore)
                    {
                        book.Avaliable_Inventory = book.Avaliable_Inventory + 1;
                    }
                    break;
                case BookStatus.Rent:
                    if (model.BeforeStatus == BookStatus.InStore)
                    {
                        book.Avaliable_Inventory = book.Avaliable_Inventory - 1;
                    }
                    break;
                case BookStatus.Error:
                    if (model.BeforeStatus == BookStatus.InStore)
                    {
                        book.Avaliable_Inventory = book.Avaliable_Inventory - 1;
                        book.Max_Inventory = book.Max_Inventory - 1;
                    }
                    else if (model.BeforeStatus == BookStatus.Rent || model.BeforeStatus == BookStatus.OutStore)
                    {
                        book.Max_Inventory = book.Max_Inventory - 1;
                    }
                    break;
                case BookStatus.OutStore:
                    if (model.BeforeStatus == BookStatus.InStore)
                    {
                        book.Avaliable_Inventory = book.Avaliable_Inventory - 1;
                    }
                    break;
            }

            this.IBookInfoDataProvider.Update(book);
        }
Ejemplo n.º 4
0
        public ActionResult EditBooks(AddDetailBookModel model)
        {
            if (model != null)
            {
                BookDetailInfo books = model.GetEntity();
                this.IBookDetailInfoDataProvider.Update(books);

                EditBooksUpdateBook(books, model);
            }

            return RedirectToAction("DetailBook", new { @id = model.BookID });
        }
Ejemplo n.º 5
0
        public ActionResult EditBooks(long id)
        {
            AddDetailBookModel model = new AddDetailBookModel();
            BookDetailInfo booksInfo = this.IBookDetailInfoDataProvider.GetBookDetailInfoByID(id);

            if (booksInfo != null)
            {
                model = AddDetailBookModel.GetViewModel(booksInfo);
                model.BookStatusList = EnumHelper.GetEnumIEnumerable<BookStatus>(booksInfo.Status);
            }

            return View(model);
        }
Ejemplo n.º 6
0
        public static AddDetailBookModel GetViewModel(BookDetailInfo bookDetailInfo)
        {
            AddDetailBookModel model = new AddDetailBookModel();
            model.ID = bookDetailInfo.ID;
            model.BookID = bookDetailInfo.BookInfo.ID;
            model.BookName = bookDetailInfo.BookInfo.BookName;
            model.ISBN = bookDetailInfo.BookInfo.ISBN;
            model.Owner = bookDetailInfo.UserInfo.DisplayName;
            model.OwnerValue = bookDetailInfo.UserInfo.ID.ToString();
            model.Status = EnumHelper.GetEnumDescription(bookDetailInfo.Status);
            model.Storage_Time = bookDetailInfo.Storage_Time.ToString(UntityContent.IOSDateTemplate);
            model.Create_Time = bookDetailInfo.CreateTime.ToString();

            model.BeforeStatus = bookDetailInfo.Status;

            //need to add logic
            model.IsUse = false;
            return model;
        }