Пример #1
0
        public HotelChain UpdateHotelChain(HotelChain hotelChain)
        {
            var forUpdate = _hotelRecordDbContext.HotelChains.Update(hotelChain);

            _hotelRecordDbContext.SaveChanges();

            return(hotelChain);
        }
Пример #2
0
        public async Task <ActionResult> DeleteConfirmed(string id)
        {
            HotelChain hotelChain = await db.HotelChain.FindAsync(id);

            db.HotelChain.Remove(hotelChain);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Пример #3
0
        public async Task <ActionResult> Edit([Bind(Include = "ChainID,ChainName")] HotelChain hotelChain)
        {
            if (ModelState.IsValid)
            {
                db.Entry(hotelChain).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(hotelChain));
        }
Пример #4
0
        public void DontShouldInstantiateAHotelChainWhenDontHaveAtLeastOneHotel()
        {
            //Arrange
            var hotels = new List <Hotel>();

            //Action
            var(hotelChain, result) = HotelChain.Construct(hotels);

            //Assert
            Assert.False(result);
            Assert.Null(hotelChain);
        }
Пример #5
0
        public async Task <ActionResult> Create([Bind(Include = "ChainID,ChainName")] HotelChain hotelChain)
        {
            if (ModelState.IsValid)
            {
                db.HotelChain.Add(hotelChain);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(hotelChain));
        }
Пример #6
0
        static void Main(string[] args)
        {
            args[0] = args[0].Replace(":", "");
            var resultEnumTryParse = Enum.TryParse(typeof(CustomerType), args[0], false, out var customerType);

            if (!resultEnumTryParse)
            {
                Utils.Error("Não foi encontrado o tipo de cliente informado.");
            }

            var daysAmount = Utils.CountDaysAmount(args);

            var interError = "Houve um erro interno referente a rede de hoteis.";

            var(nerio, resultNerio) = Hotel.Construct("Nerio", 3, 110, 90, 80, 80);
            if (!resultNerio)
            {
                Utils.Error(interError);
            }

            var(coimbra, resultCoimbra) = Hotel.Construct("Coimbra", 4, 160, 60, 110, 50);
            if (!resultCoimbra)
            {
                Utils.Error(interError);
            }

            var(manso, resultManso) = Hotel.Construct("Manso", 5, 220, 150, 100, 40);
            if (!resultManso)
            {
                Utils.Error(interError);
            }

            var hotels = new List <Hotel> {
                nerio !, coimbra !, manso !
            };

            var(hotelChain, resultHotelChain) = HotelChain.Construct(hotels);
            if (!resultHotelChain)
            {
                Utils.Error(interError);
            }

            var(hotelCheaper, resultHotelCheaper) = hotelChain.CalculateCheaper((CustomerType)customerType, daysAmount.weekDaysAmount, daysAmount.weekendDaysAmount);
            if (!resultHotelCheaper)
            {
                Utils.Error(interError);
            }

            Console.WriteLine($"O Hotel mais barato da rede é o: {hotelCheaper}");
        }
    }
Пример #7
0
        // GET: HotelChains/Delete/5
        public async Task <ActionResult> Delete(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            HotelChain hotelChain = await db.HotelChain.FindAsync(id);

            if (hotelChain == null)
            {
                return(HttpNotFound());
            }
            return(View(hotelChain));
        }
Пример #8
0
        public void ShouldInstantiateWithSuccessAHotelChain()
        {
            //Arrange
            var(nerio, _)   = Hotel.Construct("Nerio", 3, 110, 80, 90, 80);
            var(coimbra, _) = Hotel.Construct("Coimbra", 4, 160, 110, 60, 50);
            var(manso, _)   = Hotel.Construct("Manso", 5, 220, 100, 150, 40);

            var hotels = new List <Hotel> {
                nerio !, coimbra !, manso !
            };

            //Action
            var(hotelChain, result) = HotelChain.Construct(hotels);

            //Assert
            Assert.NotNull(hotelChain);
            Assert.True(result);

            Assert.Equal(hotels.Count, hotelChain !.Quantity);
        }
Пример #9
0
        public void ShouldIndicateTheHotelCheaperAtThePeriodOfDatesOfAReservationAndTheTypeOfCustomer(CustomerType customerType, int weekDaysAmount, int weekendDaysAmount, string expectedResult)
        {
            //Arrange
            var(nerio, _)   = Hotel.Construct("Nerio", 3, 110, 90, 80, 80);
            var(coimbra, _) = Hotel.Construct("Coimbra", 4, 160, 60, 110, 50);
            var(manso, _)   = Hotel.Construct("Manso", 5, 220, 150, 100, 40);

            var hotels = new List <Hotel> {
                nerio !, coimbra !, manso !
            };

            var(hotelChain, _) = HotelChain.Construct(hotels);

            //Action
            var(hotelCheaper, result) = hotelChain !.CalculateCheaper(customerType, weekDaysAmount, weekendDaysAmount);

            //Assert
            Assert.True(result);

            Assert.NotNull(hotelCheaper);
            Assert.NotEmpty(hotelCheaper);
            Assert.Equal(expectedResult, hotelCheaper);
        }
    }
Пример #10
0
 public HotelChain UpdateHotelChain(HotelChain hotelChain)
 {
     return(_hotelChainRepositori.UpdateHotelChain(hotelChain));
 }
Пример #11
0
 public void SaveHotelChain(HotelChain hotelChain)
 {
     _hotelChainRepositori.SaveHotelChain(hotelChain);
 }
Пример #12
0
 public void AddChain(HotelChain chain)
 {
     throw new NotImplementedException();
 }
Пример #13
0
 public void SaveHotelChain(HotelChain hotelChain)
 {
     _hotelRecordDbContext.HotelChains.Add(hotelChain);
     _hotelRecordDbContext.SaveChanges();
 }