public void RentalTestSetup() { idtMock = Substitute.For <IDatateTime>(); sut = new Rentals(idtMock); }
public IHttpActionResult CreateNewRentals(NewRentalDto newRental) { //throw new NotImplementedException(); var customer = _context.Customers.Single( c => c.Id == newRental.CustomerId); var movies = _context.Movies.Where( m => newRental.MovieIds.Contains(m.Id)); foreach (var movie in movies) { if (movie.NumberAvailable == 0) { return(BadRequest("Movie not available")); } movie.NumberAvailable--; var rental = new Rentals { Customer = customer, Movie = movie, DateRented = DateTime.Now }; _context.Rentals.Add(rental); } _context.SaveChanges(); return(Ok()); }
public void ClearDatabase() { #if MSSQL Console.WriteLine("qfklqsjdfkljqsdlfjiljsdfkljqsdkldfjklsqdjdhfjsqdhfjqsdhljkfklqsdjfklqsdjfkljsqddlkfjlsqdkjf"); RentalItems.RemoveRange(RentalItems); Rentals.RemoveRange(Rentals); Users.RemoveRange(Users); BookCopies.RemoveRange(BookCopies); Books.RemoveRange(Books); Categories.RemoveRange(Categories); #else #endif SaveChanges(); Reseed(nameof(Users)); Reseed(nameof(Books)); Reseed(nameof(Rentals)); Reseed(nameof(BookCopies)); Reseed(nameof(Categories)); Reseed(nameof(RentalItems)); /** * Décommenter la ligne suivante pour réinitialiser le compteur de clef autoincrementée */ //Reseed(nameof(Messages)); }
private void ReturnMovie() { if (_dialogService.ShowMessageBox( this, Local.Strings.txtReturnConfirmation, Local.Strings.txtConfirmationRequired, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { var rentalsToRemove = new List <Rental>(); foreach (var item in Rentals.Where(i => i.IsSelected)) { rentalsToRemove.Add(item.Model); } _videoStoreService.DeleteRentals(rentalsToRemove); // refresh _rentals = _videoStoreService.GetRentals(); RefreshRentals(); RefreshDatesOfRental(); RefreshDueDates(); RefreshUsers(); } }
public void ClearDatabase() { #if MSSQL Books.RemoveRange(Books); Users.RemoveRange(Users); BookCopies.RemoveRange(BookCopies); RentalItems.RemoveRange(RentalItems); Rentals.RemoveRange(Rentals); Categories.RemoveRange(Categories .Include(nameof(Category.Books)) ); #else Categories.RemoveRange(Categories .Include(nameof(Category.Books)) ); #endif SaveChanges(); /** * Décommenter la ligne suivante pour réinitialiser le compteur de clef autoincrementée */ Reseed(nameof(Users)); Reseed(nameof(Books)); Reseed(nameof(BookCopies)); Reseed(nameof(Categories)); Reseed(nameof(Rentals)); Reseed(nameof(RentalItems)); }
public virtual Rental AddRental(Video video) { var rental = new Rental(this, video); Rentals.Add(rental); return(rental); }
public IResult Add(Rentals entity) { entity.RentDate = DateTime.Now; rentalDal.Add(entity); return(new SuccessResult("Başarılı bir şekilde eklendi")); }
public IHttpActionResult CreateNewRentals(NewRentals newRental) { var customer = db.Customers.Single( x => x.Id == newRental.Custmerid); var movies = db.Movies.Where( x => newRental.Movieids.Contains(x.Id)); foreach (var movie in movies) { if (movie.MemberAvalible == 0) { return(BadRequest("One or more Movies are invalid. ")); } movie.MemberAvalible--; var rental = new Rentals { Customers = customer, Movies = movie, DateRented = DateTime.Now }; db.Rentals.Add(rental); } db.SaveChanges(); return(Ok()); }
public static Rentals convertRental(RentalRepresentation rental) { Rentals convertedRental = new Rentals() { actualPrice = rental.actualPrice, customerID = rental.customer.id, discount = (float)rental.discount * 100, isClean = rental.isClean, rentalID = rental.id, rentalEnd = rental.rentalEnd, isPaid = rental.isPaid, payTypeID = rental.payType.id, rentalRealEnd = rental.rentalRealEnd, rentalStart = rental.rentalStart, toolID = rental.tool.id }; if (rental.group != null && rental.group.id != default(long)) { convertedRental.groupID = rental.group.id; } convertedRental.Tools = convertTool(rental.tool); if (rental.customer.isFirm && rental.contact != null) { convertedRental.contactID = rental.contact.id; convertedRental.Customers1 = convertCustomer(rental.contact); } return(convertedRental); }
public IHttpActionResult PutRentals(int id, Rentals rentals) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != rentals.RentalID) { return(BadRequest()); } db.Entry(rentals).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!RentalsExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
private void Window_Loaded(object sender, RoutedEventArgs e) { rentals = new Rentals(); residences = new Residences(); tenants = new Tenants(); PopulateResidences(); }
public IHttpActionResult Post(RentalsDto rentalsDto) { var customer = _context.Customer.Single(c => c.Id == rentalsDto.CustomerId); var movies = _context.Movies.Where(c => rentalsDto.MoviesId.Contains(c.Id)).ToList(); if (customer == null && movies == null) { return(NotFound()); } foreach (var movie in movies) { if (movie.NumbersAvailable == 0) { return(BadRequest("Movie Not Available")); } movie.NumbersAvailable--; var rent = new Rentals { DateRented = DateTime.Now, Customer = customer, Movies = movie, }; _context.Rentals.Add(rent); } _context.SaveChanges(); return(Ok()); }
public ActionResult Rent(string book) { var user = User.Identity.Name; var rentals = db.Rentals; IEnumerable <Rentals> userRentals = rentals.Where(m => m.rentalUser == user && m.rentalExpiration >= DateTime.Today); var dupCheck = false; foreach (Rentals rental in userRentals) { if (rental.rentalBook == book) { dupCheck = true; } } if (dupCheck) { return(RedirectToAction("Index")); } else { var rental = new Rentals { rentalUser = User.Identity.Name, rentalExpiration = DateTime.Today.AddDays(3) }; rental.rentalBook = book; db.Rentals.Add(rental); db.SaveChanges(); return(RedirectToAction("Index")); } }
async Task LoadRentalsAsync() { LoadStatus = LoadStatus.Loading; Rentals.Clear(); Rentals.AddRange(await _rentalService.GetRentalsAsync(Owner)); LoadStatus = LoadStatus.Loaded; }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Location")] Rentals rentals) { if (id != rentals.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(rentals); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RentalsExists(rentals.Id)) { return(NotFound()); } else { throw; } } ApplicationUser appUser = await GetCurrentUserAsync(); rentals.ApplicationUserId = appUser.Id; await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(rentals)); }
public IResult Add(Rentals rentals) { ValidationTool.Validate(new RentalsValidator(), rentals); _rentalsDal.Add(rentals); return(new SuccessResult(Messages.RentalAdded)); }
//GET Rentals/Book public async Task <IActionResult> Book(int id) { ApplicationUser appUser = await GetCurrentUserAsync(); List <User> users = await _context.User.ToListAsync(); Rentals rentals = await _context.Rentals.FirstOrDefaultAsync(r => r.Id == id); RentalVM vm = new RentalVM() { //Get Rentals to display Name, Location for View Rentals = await _context.Rentals.FirstOrDefaultAsync(r => r.Id == id), UserOptions = users.Where(u => u.ApplicationUserId == appUser.Id && u.isArchived == false).Select(u => new SelectListItem { Value = u.Id.ToString(), Text = u.FirstName }) .ToList() }; vm.UserOptions.Insert(0, new SelectListItem { Text = "Choose a User", Value = "0" }); return(View(vm)); }
public void Setup() { date = Substitute.For <IDateTime>(); sut = new Rentals(date); date.Now().Returns(new System.DateTime(1222, 12, 12)); }
private static void GoCarRent() { RentalsManager rentalmanager = new RentalsManager(new EfRentalsDAL()); Console.WriteLine("(int)RentalId:"); int RentalId1 = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("(int)CarId:"); int CarId1 = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("(int)CustomerId:"); int CustomerId1 = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("(DateTime)RentDate:"); DateTime RentDate1 = Convert.ToDateTime(Console.ReadLine()); Console.WriteLine("(DateTime)ReturnDate:"); DateTime ReturnDate1 = Convert.ToDateTime(Console.ReadLine()); Rentals rental1 = new Rentals(); rental1 = new Rentals() { RentalId = RentalId1, CarId = CarId1, CustomerId = CustomerId1, RentDate = RentDate1, ReturnDate = ReturnDate1 }; }
public void ClearDatabase() { #if MSSQL Categories.RemoveRange(Categories); RentalItems.RemoveRange(RentalItems); BookCopies.RemoveRange(BookCopies); Books.RemoveRange(Books); Rentals.RemoveRange(Rentals); Users.RemoveRange(Users); #else Categories.RemoveRange(Categories); BookCopies.RemoveRange(BookCopies .Include(nameof(BookCopy.RentalItems)) ); Books.RemoveRange(Books); Users.RemoveRange(Users .Include(nameof(User.Rentals)) ); #endif SaveChanges(); Reseed(nameof(Users)); Reseed(nameof(Books)); Reseed(nameof(BookCopies)); Reseed(nameof(Categories)); Reseed(nameof(Rentals)); Reseed(nameof(RentalItems)); }
public WinRental(Residence residence, Rentals rentals, Tenants tenants) { this.residence = residence; this.rentals = rentals; this.tenants = tenants; InitializeComponent(); }
public async Task <IActionResult> Edit(Guid id, [Bind("Id,TimeStamp,Description,ImagePath")] Rentals rentals) { if (id != rentals.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(rentals); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RentalsExists(rentals.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(rentals)); }
public void StartMovieRental(NewRentalViewModel rvm) { var config = new MapperConfiguration(cfg => { cfg.CreateMap <NewRentalViewModel, Rentals>(); cfg.IgnoreUnmapped(); }); IMapper mapper = config.CreateMapper(); Rentals r = mapper.Map <NewRentalViewModel, Rentals>(rvm); rr.StartMovieRental(r); }
public void VideoStoreSetup() { idtMock = Substitute.For <IDatateTime>(); Rental = new Rentals(idtMock); sut = new VideoStore(Rental); }
public async Task <Rentals> SaveRental(Rentals rental) { using var context = _contextFactory.CreateDbContext(); var r = context.Rentals.Add(rental); await context.SaveChangesAsync(); return(r.Entity); }
public ActionResult DeleteConfirmed(int id) { Rentals rentals = db.Rentals.Find(id); db.Rentals.Remove(rentals); db.SaveChanges(); return(RedirectToAction("Index")); }
public int Rentals_Add(Rentals item) { using (var context = new StarTEDContext()) { context.Rentals.Add(item); context.SaveChanges(); return(item.RentalID); } }
public IResult Add(Rentals rental) { if (rental.RentDate == null) { return(new ErrorResult("Araba teslim edilmemiş")); } _rentalDal.Add(rental); return(new SuccessResult()); }
public IResult Add(Rentals rental) { if (rental.ReturnDate == null) { return(new ErrorResult()); } _rentalDal.Add(rental); return(new SuccessResult()); }
public IResult Add(Rentals rent) { if (rent.ReturnDate == null) { return(new ErrorResult(Messages.Rented)); } _rentalsDal.Add(rent); return(new SuccessResult(Messages.RentOk)); }