public HotelChain UpdateHotelChain(HotelChain hotelChain) { var forUpdate = _hotelRecordDbContext.HotelChains.Update(hotelChain); _hotelRecordDbContext.SaveChanges(); return(hotelChain); }
public async Task <ActionResult> DeleteConfirmed(string id) { HotelChain hotelChain = await db.HotelChain.FindAsync(id); db.HotelChain.Remove(hotelChain); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
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)); }
public void DontShouldInstantiateAHotelChainWhenDontHaveAtLeastOneHotel() { //Arrange var hotels = new List <Hotel>(); //Action var(hotelChain, result) = HotelChain.Construct(hotels); //Assert Assert.False(result); Assert.Null(hotelChain); }
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)); }
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}"); } }
// 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)); }
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); }
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); } }
public HotelChain UpdateHotelChain(HotelChain hotelChain) { return(_hotelChainRepositori.UpdateHotelChain(hotelChain)); }
public void SaveHotelChain(HotelChain hotelChain) { _hotelChainRepositori.SaveHotelChain(hotelChain); }
public void AddChain(HotelChain chain) { throw new NotImplementedException(); }
public void SaveHotelChain(HotelChain hotelChain) { _hotelRecordDbContext.HotelChains.Add(hotelChain); _hotelRecordDbContext.SaveChanges(); }