// GET: Thing/Lend/5 public ActionResult Lend(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var thing = Service.FindById(id.Value); if (thing == null) { return(HttpNotFound()); } var view = new LendViewModel() { ThingID = thing.ID, ThingName = thing.Name, ThingImageLink = thing.ImageLink, ThingCategoryName = thing.Category.Name, LentDate = thing.LentDate == null ? DateTime.Now.Date : thing.LentDate.Value, PersonID = thing.PersonID }; LoadPeople(thing.PersonID); return(View(view)); }
// GET: Lends/Create public virtual ActionResult Create() { ApplicationUser auser = System.Web.HttpContext.Current.GetOwinContext().GetUserManager <ApplicationUserManager>().FindById(System.Web.HttpContext.Current.User.Identity.GetUserId()); var dbUser = _userRepository.GetUserByEmail(auser.Email); //check lenditems quanitty / availability var lenditems = _mapper.Map <IEnumerable <LendItemViewModel> >(_lendItemRepository.GetLendItems().OrderBy(d => d.Id)).ToList(); var sortedItemList = new List <LendItemViewModel>(); foreach (var item in lenditems) { if (item.Avialable != 0 && item.Avialable <= item.Quantity) { sortedItemList.Add(item); } } var viewmodel = new LendViewModel() { From = DateTime.Now, LendItemsList = sortedItemList, UserList = _userRepository.GetUsers(), CurrentUserwithID = dbUser.UserName + " (" + dbUser.Id + ")" }; return(View(viewmodel)); }
public IActionResult LendGame(LendViewModel lendViewModel) { var game = _gameRepository.getById(lendViewModel.Game.GameId); Customer c = FindCustomerByName(_customerRepository.GetAll().ToList()); var sum = c.Money - game.Price; if (sum <= 0) { return(View("Error")); } else { c.Money = sum; game.Customer = c; _gameRepository.Update(game); _customerRepository.Update(c); var model = new LendViewModel { Customers = c, Game = game, Date = DateTime.Now }; _lendDataProvider.AddData(model); return(RedirectToAction("List")); } }
public IActionResult LendBook(LendViewModel lendViewModel) { var book = bookRepositery.GetById(lendViewModel.book.BookId); var customer = customerRepositery.GetById((int)lendViewModel.book.CustomerId); book.Customer = customer; bookRepositery.Update(book); return(RedirectToAction("List")); }
public IActionResult LendBook(LendViewModel lendViewModel) { var book = _bookRepository.GetById(lendViewModel.Book.BookId); var customer = _customerRepository.GetById(lendViewModel.Book.BorrowerId); book.Borrower = customer; _bookRepository.Update(book); return(RedirectToAction("List")); }
public IActionResult LendBook(int bookId) { var Lendvm = new LendViewModel() { book = bookRepositery.GetById(bookId), customers = customerRepositery.GetAll() }; return(View(Lendvm)); }
// GET: Lends/Details/5 public virtual ActionResult Details(int Id) { var model = _lendRepository.GetLendByID(Id); if (model == null) { return(RedirectToAction(Actions.Index())); } LendViewModel vm = _mapper.Map <Lend, LendViewModel>(model); LendItemViewModel ItemVM = _mapper.Map <LendItem, LendItemViewModel>(model.LendItem); LendReturnViewModel lrVM = new LendReturnViewModel(); //get images of LendReturn if (model.LendReturn != null) { lrVM = _mapper.Map <LendReturn, LendReturnViewModel>(model.LendReturn); if (lrVM.FileId != null) { File lendreturnImages = _fileRepository.GetFileById(lrVM.FileId.Value); List <FileViewModel> lrimageslist = new List <FileViewModel>(); FileViewModel lrFileVM = _mapper.Map <File, FileViewModel>(lendreturnImages); lrimageslist.Add(lrFileVM); //add values to Return VM lrVM.ReturnImageViewModels = lrimageslist.AsEnumerable(); } lrVM.CreatedBy = model.LendReturn.User; } //get images of LendItem if (ItemVM.FileId != null) { File lenditemImages = _fileRepository.GetFileById(ItemVM.FileId.Value); List <FileViewModel> listimages = new List <FileViewModel>(); FileViewModel itemFileVM = _mapper.Map <File, FileViewModel>(lenditemImages); listimages.Add(itemFileVM); //add values to ItemVM ItemVM.ItemImageViewModels = listimages.AsEnumerable(); } ItemVM.CreatedBy = model.LendItem.User; //stick all to LendVM vm.CreatedBy = model.User; vm.SelectedLendUser = model.LendUser; vm.SelectedLendItem = ItemVM; if (lrVM.Id != 0) { vm.LendReturn = lrVM; } return(View(vm)); }
public IActionResult LendCar(int carId) { var lendVM = new LendViewModel() { Car = _carRepository.GetById(carId), Customers = _customerRepository.GetAll() }; return(View(lendVM)); }
public IActionResult LendBook(int id) { var lendBook = new LendViewModel { Book = _bookRepository.FindById(id), Customers = _customerRepository.FindAll() }; return(View(lendBook)); }
public IActionResult LendBook(int bookId) { var lendVM = new LendViewModel { Book = _bookRepository.GetById(bookId), Customers = _customerRepository.GetAll() }; return(View(lendVM)); }
public IActionResult LendBook(int bookId) { var lendViewModel = new LendViewModel() { Book = new BookHandler().GetBookById(bookId), Customers = new CustomerHandler().GetAllCustomer() }; return(View(lendViewModel)); }
public IActionResult LendBook(LendViewModel lendVM) { var book = _bookRepository.GetById(lendVM.Book.BookId); book.BorrowerId = lendVM.Book.BorrowerId; _bookRepository.Update(book); return(RedirectToAction("List")); }
public IActionResult LendAlbum(int albumId) { var lendVM = new LendViewModel() { Album = _albumRepository.GetById(albumId), Customers = _customerRepository.GetAll() }; return(View(lendVM)); }
public IActionResult LendAlbum(LendViewModel lendViewModel) { var album = _albumRepository.GetById(lendViewModel.Album.AlbumId); var customer = _customerRepository.GetById(lendViewModel.Album.BorrowerId); album.Borrower = customer; _albumRepository.Update(album); return(RedirectToAction("List")); }
public IActionResult LendBook(int bookId) { var LendBookVM = new LendViewModel { book = _bookRepository.GetById(bookId), Costumers = _costumerRepository.GetAll() }; return(View(LendBookVM)); }
public IActionResult LendBook(LendViewModel lendViewModel) { // Update the database var book = _bookRepository.GetById(lendViewModel.Book.BookID); var customer = _customerRepository.GetById(lendViewModel.Book.BorrowerId); book.Borrower = customer; _bookRepository.Update(book); // Redirect to the list view return(RedirectToAction("List")); }
public IActionResult LendCar(LendViewModel lendViewModel) { var car = _carRepository.GetById(lendViewModel.Car.CarId); var customer = _customerRepository.GetById(lendViewModel.Car.BorrowerId); car.Borrower = customer; _carRepository.Update(car); return(RedirectToAction("List")); }
public IActionResult LendMusic(int musicID) { // load current music and all customers var lendVM = new LendViewModel() { Music = _musicRepository.GetByID(musicID), Customers = _customerRepository.GetAll() }; // Send data to the Lend view return(View(lendVM)); }
public IActionResult LendBook(int bookId) { //cargo el libro y los usuarios var lendVM = new LendViewModel() { Book = _bookRepository.GetById(bookId), Customers = _customerRepository.GetAll() }; // Send data to the Lend view return(View(lendVM)); }
public IActionResult LendBook(int bookID) { //Load CurrentBook and All Customer //Send data to the lend view var LendVm = new LendViewModel() { Book = _bookRepository.GetById(bookID), Customers = _customerRepository.GetAll() }; return(View(LendVm)); }
public IActionResult Lend(LendViewModel vm) { // Update Database var book = _bookRepository.GetById(vm.Book.BookId); var customer = _customerRepository.GetById(vm.Book.BorrowerId); book.Borrower = customer; _bookRepository.Update(book); return(RedirectToAction("List")); }
public IActionResult LendBook(int bookId) { //load current book and all customers var lendVM = new LendViewModel() { Book = _bookRepository.GetById(bookId), Customers = _customerRepository.GetAll() }; //send data to the lend view return(View(lendVM)); }
// Lends/Delete/5 public virtual ActionResult Delete(int?id) { var model = _lendRepository.GetLendByID(id.Value); if (model == null) { return(RedirectToAction(Actions.Index())); } LendViewModel vm = _mapper.Map <Lend, LendViewModel>(model); return(View(vm)); }
public IActionResult LendMusic(LendViewModel lendViewModel) { // update the database var music = _musicRepository.GetByID(lendViewModel.Music.MusicID); var customer = _customerRepository.GetByID(lendViewModel.Music.BorrowerID); music.Borrower = customer; _musicRepository.Update(music); // redirect to the list view return(RedirectToAction("List")); }
// public IActionResult LendBook(int bookId) { //Load current book and all customers //In order to send data to the Lend view we need a ViewModel Class var lendVM = new LendViewModel() { Book = _bookRepository.GetById(bookId), Customers = _customerRepository.GetAll() }; //Send the data to the lend view return(View(lendVM)); }
public IActionResult LendGame(int gameId) { Customer c = FindCustomerByName(_customerRepository.GetAll().ToList()); var lendVM = new LendViewModel() { Game = _gameRepository.getById(gameId), Customers = c, Date = DateTime.Now }; return(View(lendVM)); }
public IActionResult LendBook(LendViewModel lendViewModel) { //update the database var book = _bookrepository.GetById(lendViewModel.Book.BookId); var customer = _customerRepository.GetById(lendViewModel.Book.BorrowerId); book.Borrower = customer; book.BorrowerId = customer.CustomerId; _bookrepository.Update(book); return(RedirectToAction("List")); //return View("List"); }
public IActionResult LendBook(LendViewModel lendVm) { /* * we have to add that book to the list of borrowed books of the customer,and */ var book = _bookRepository.FindById(lendVm.Book.BookId); book.BorrowerId = lendVm.Book.BorrowerId; _bookRepository.Update(book); return(RedirectToAction("Index")); }
public IActionResult LendBook(LendViewModel lendVM) { if (!Admin.logged) { return(RedirectToAction("Login", "Admin", 0)); } var book = _bookRepository.GetById(lendVM.Book.BookId); book.BorrowerId = lendVM.Book.BorrowerId; book.DateB = DateTime.Now.ToString(); _bookRepository.Update(book); return(RedirectToAction("List")); }
public virtual ActionResult Edit(LendViewModel viewModel) { //get data from DB var model = _lendRepository.GetLendByID(viewModel.Id); var updatedLendmodel = _mapper.Map <LendViewModel, Lend>(viewModel); //updating values to model model.From = updatedLendmodel.From; model.To = updatedLendmodel.To; _lendRepository.UpdateLend(model); return(RedirectToAction("Index")); }