public ActionResult EditBook(int bookId) { var result = bookdataProvider.GetBookById(bookId); var authors = authorDataProvider.GetAllAuthor("", "", "").ToList(); ViewBag.AuthorId = new SelectList(authors, "AuthorId", "Name", result.AuthorId); //დეფოულტ მნიშვნელობა არ ჯდება var conditions = adminDataProvider.GetAllCondition().ToList(); ViewBag.ConditionId = new SelectList(conditions, "ConditionId", "Name", result.ConditionId); //დეფოულტ მნიშვნელობა არ ჯდება var genres = genreDataProvider.GetAllGenre("").ToList(); ViewBag.GenreId = new SelectList(genres, "GenreId", "Name", result.GenreId); //დეფოულტ მნიშვნელობა არ ჯდება var dealTypes = adminDataProvider.GetAllDealType().ToList(); ViewBag.DealTypeId = new SelectList(dealTypes, "DealTypeId", "Name", result.DealTypeId); //დეფოულტ მნიშვნელობა არ ჯდება var customBook = new CustomBook() { Name = result.Name, AuthorId = result.AuthorId, ConditionId = result.ConditionId, GenreId = result.GenreId, DealTypeId = result.DealTypeId, IsActive = result.IsActive, UserId = result.UserId, Price = result.Price }; return(View(customBook)); }
public ActionResult CreateBook(CustomBook model) { bookdataProvider.AddBook(new Book { Name = model.Name, AuthorId = model.AuthorId, ConditionId = model.ConditionId, GenreId = model.GenreId, DealTypeId = model.DealTypeId, IsActive = 1, UserId = LoginHelper.CurrentUser().Id, //არ მუშაობს :( //მგონი ამუშავდა :დ Price = model.Price }); return(RedirectToAction("BookList")); }
public IEnumerable <CustomBook> Get() { List <CustomBook> custom = new List <CustomBook>(); var res = db.books.ToList(); foreach (var i in res) { CustomBook b = new CustomBook(); b.bid = i.bid; b.bname = i.bname; b.bgener = i.bgener; b.bprice = i.bprice; custom.Add(b); } return(custom); }
public CustomBook Get(int id) { CustomBook b = new CustomBook(); var i = (from c in db.books where c.bid == id select new { BID = c.bid, BNAME = c.bname, BGENRE = c.bgener, BPRICE = c.bprice, }).SingleOrDefault(); b.bid = i.BID; b.bname = i.BNAME; b.bgener = i.BGENRE; b.bprice = i.BPRICE; return(b); }
public ActionResult EditBook(CustomBook model) { bookdataProvider.EditBook(model); return(RedirectToAction("BookList")); }