public ActionResult DeleteConfirmed(int id)
        {
            Casette casette = db.Casettes.Find(id);

            db.Casettes.Remove(casette);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public int AddCasette(VideoTitle title)
        {
            int id      = GetNextCasetteId();
            var casette = new Casette(id, title);

            casettes.Add(casette);
            return(id);
        }
Exemple #3
0
 public Rental CreateRental(int customerId, Casette casette)
 {
     return(new Rental(new Customer(customerId), casette)
     {
         RentalDays = 0,
         Price = 0,
         BonusPointsPayed = 0
     });
 }
Exemple #4
0
 internal static bool GetConfirmationForTerms(Casette casette, RentalOptions options)
 {
     Console.WriteLine();
     Console.WriteLine(
         $"You have selected:\n" +
         $"{casette.Title.Name}, {casette.Title.Year} ({options.TitleType}) {options.RentalDays} days ---> {options.Price} Eur");
     Console.WriteLine();
     return(GetConfirmation("Agree to rent? (y/n) ", "y"));
 }
Exemple #5
0
 internal static void ShowReceiptWithMoney(Casette casette, RentalOptions options)
 {
     Console.WriteLine();
     Console.WriteLine(
         "Rented:\n" +
         $"{casette.Title.Name}, {casette.Title.Year} ({casette.Title.Type}) {options.RentalDays} days {options.Price} Eur");
     Console.WriteLine();
     Pause();
 }
        private Rental CreateCustomerAndRental()
        {
            var customer = new Customer(repo.Customers.Count + 1);

            repo.Customers.Add(customer);
            var casette = new Casette(repo.Casettes.Count + 1, helper.GetBrandNewTitle());

            return(helper.CreateRental(customer.Id, casette));
        }
Exemple #7
0
 internal static void ShowReceiptWithPoints(Casette casette, RentalOptions options, int bonusPointsRemaining)
 {
     Console.WriteLine();
     Console.WriteLine(
         "Rented:\n" +
         $"{casette.Title.Name}, {casette.Title.Year} ({casette.Title.Type}) {options.RentalDays} days (Paid with {options.PriceInPoints} bonus points)\n" +
         $"Remaining bonus points: {bonusPointsRemaining}");
     Console.WriteLine();
     Pause();
 }
        public void When_GetCasette_Then_CorrectCasetteIsReturned()
        {
            var casette = new Casette(repo.Casettes.Count + 1, helper.GetBrandNewTitle());

            repo.Casettes.Add(casette);

            var found = repo.GetCasette(casette.Id);

            Assert.AreEqual(casette.Id, found.Id);
        }
        public void When_RemoveCasette_Then_CasetteIsRemoved()
        {
            var casette = new Casette(repo.Casettes.Count + 1, helper.GetBrandNewTitle());

            repo.Casettes.Add(casette);

            repo.RemoveCasette(casette.Id);

            Assert.AreEqual(0, repo.Casettes.Count);
        }
 public ActionResult Edit([Bind(Include = "id_casette,clave,estado,formato")] Casette casette)
 {
     if (ModelState.IsValid)
     {
         db.Entry(casette).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.formato = new SelectList(db.Formatoes, "id_formato", "formato1", casette.formato);
     return(View(casette));
 }
        public ActionResult Create([Bind(Include = "id_casette,clave,estado,formato")] Casette casette)
        {
            if (ModelState.IsValid)
            {
                db.Casettes.Add(casette);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.formato = new SelectList(db.Formatoes, "id_formato", "formato1", casette.formato);
            return(View(casette));
        }
Exemple #12
0
        public VideoTitle AddNewTestTitleWithOneCasette()
        {
            var title = GetBrandNewTitle();

            repo.Titles.Add(title);

            var casette = new Casette(repo.Casettes.Count + 1, title);

            repo.Casettes.Add(casette);

            return(title);
        }
        // GET: Casettes/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Casette casette = db.Casettes.Find(id);

            if (casette == null)
            {
                return(HttpNotFound());
            }
            return(View(casette));
        }
        public void When_GetCasetteOnShelfByTitle_Then_CasetteWithCorrectTitleAndNoRentalReturned()
        {
            var wrongTitle    = helper.AddNewTestTitleWithOneCasette();
            var title         = helper.AddNewTestTitleWithOneCasette();
            var rentedCasette = new Casette(repo.Casettes.Count + 1, title);

            repo.Casettes.Add(rentedCasette);
            repo.Rentals.Add(helper.CreateRental(1, rentedCasette));

            var casette = repo.GetCasetteOnShelfByTitle(title.Id);

            Assert.AreEqual(title.Id, casette.Title.Id);
            Assert.AreEqual(0, repo.Rentals.Count(x => x.Casette.Id == casette.Id && x.IsActive));
        }
        // GET: Casettes/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Casette casette = db.Casettes.Find(id);

            if (casette == null)
            {
                return(HttpNotFound());
            }
            ViewBag.formato = new SelectList(db.Formatoes, "id_formato", "formato1", casette.formato);
            return(View(casette));
        }
        public void When_GetAllActiveRentals_Then_AllActiveReturned()
        {
            Rental rental1 = CreateCustomerAndRental();

            repo.Rentals.Add(rental1);
            Rental rental2 = CreateCustomerAndRental();

            repo.Rentals.Add(rental2);
            Casette renturnedCasette = new Casette(repo.Casettes.Count + 1, helper.GetBrandNewTitle());
            Rental  rental3          = helper.CreateRental(rental2.Customer.Id, renturnedCasette);

            rental3.IsActive = false;
            repo.Rentals.Add(rental3);

            var rentals = repo.GetAllActiveRentals();

            Assert.AreEqual(2, rentals.Count);
        }
        public void When_GetAllTitlesOnShelf_Then_ReturnsOnlyThatHasAnyCasetteOnShelf()
        {
            var expectedTitles = new List <VideoTitle>();

            expectedTitles.Add(helper.AddNewTestTitleWithOneCasette());
            expectedTitles.Add(helper.AddNewTestTitleWithOneCasette());

            var title = helper.GetBrandNewTitle();

            repo.Titles.Add(title);
            var casette = new Casette(repo.Casettes.Count + 1, title);

            repo.Casettes.Add(casette);
            repo.Rentals.Add(helper.CreateRental(1, casette));

            var titles = repo.GetAllTitlesOnShelf();

            CollectionAssert.AreEqual(expectedTitles, titles);
        }
Exemple #18
0
    private void Start()
    {
        //highScore = PlayerPrefs.GetInt("Highscore", highScore);
        score = 0;

        Application.targetFrameRate = 60;
        Time.timeScale = 1;

        cameraObject       = Camera.main.gameObject;
        spawner            = FindObjectOfType <Spawner>();
        player             = FindObjectOfType <Casette>();
        spawner.enemySpeed = moveSpeed;

        scoreText.text     = score.ToString();
        highscoreText.text = highScore.ToString();

        _originalPos = cameraObject.transform.localPosition;

        pauseMenu.SetActive(false);
    }
Exemple #19
0
 private void CalculateTerms()
 {
     casette = store.GetCasetteOnShelfByTitle(film.Id);
     options = store.GetRentalOptions(customer.Id, casette.Title.Type, dayCount);
 }
        private void AddRental(Customer customer, VideoTitle title, int casetteId)
        {
            var casette = new Casette(casetteId, title);

            repo.Rentals.Add(new Rental(customer, casette));
        }