Ejemplo n.º 1
0
        public ActionResult DeleteConfirmed(int id)
        {
            Casette casette = db.Casettes.Find(id);

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

            casettes.Add(casette);
            return(id);
        }
Ejemplo n.º 3
0
 public Rental CreateRental(int customerId, Casette casette)
 {
     return(new Rental(new Customer(customerId), casette)
     {
         RentalDays = 0,
         Price = 0,
         BonusPointsPayed = 0
     });
 }
Ejemplo n.º 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"));
 }
Ejemplo n.º 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();
 }
Ejemplo n.º 6
0
        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));
        }
Ejemplo n.º 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();
 }
Ejemplo n.º 8
0
        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);
        }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 10
0
 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));
 }
Ejemplo n.º 11
0
        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));
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 13
0
        // 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));
        }
Ejemplo n.º 14
0
        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));
        }
Ejemplo n.º 15
0
        // 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));
        }
Ejemplo n.º 16
0
        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);
        }
Ejemplo n.º 17
0
        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);
        }
Ejemplo n.º 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);
    }
Ejemplo n.º 19
0
 private void CalculateTerms()
 {
     casette = store.GetCasetteOnShelfByTitle(film.Id);
     options = store.GetRentalOptions(customer.Id, casette.Title.Type, dayCount);
 }
Ejemplo n.º 20
0
        private void AddRental(Customer customer, VideoTitle title, int casetteId)
        {
            var casette = new Casette(casetteId, title);

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