// GET: Accommodations/Details/id //[Authorize(Roles = "Host,Tenant")] public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var currentAccommodation = _db.Accommodations.Find(id); var viewModel = new DetailsViewModel(currentAccommodation) { Amenities = AmenitiesManager.GetForAccommodation(id), Availabilities = AvailabilityManager.GetForAccommodation(id), Images = _db.Images.Where(i => i.AccommodationId == id), Category = _db.Categories.Find(currentAccommodation.CategoryId).Description }; if (viewModel == null) { return(HttpNotFound()); } return(View("Details", viewModel)); }
public void TestUpdateAvailabilitySuccess() { //Arrange EmployeeAvailability oldAvailability = new EmployeeAvailability() { AvailabilityID = 1, EmployeeID = 100000, DayOfWeek = "Monday", StartTime = new DateTime(2020, 4, 21, 10, 0, 0).ToString(), EndTime = new DateTime(2020, 4, 21, 23, 0, 0).ToString() }; EmployeeAvailability availability = new EmployeeAvailability() { AvailabilityID = 1, EmployeeID = 100000, DayOfWeek = "Tuesday", StartTime = new DateTime(2020, 4, 21, 10, 0, 0).ToShortTimeString(), EndTime = new DateTime(2020, 4, 21, 23, 0, 0).ToShortTimeString() }; IAvailabilityManager _availabilityManager = new AvailabilityManager(_availabilityAccessor); bool expectResult = true; //Act bool actualResult = _availabilityManager.EditAvailability(availability, oldAvailability); //Assert Assert.AreEqual(expectResult, actualResult); }
public static CheckAvailabilityResult GetCheckAvailabilityResult(Hotels.Common.Models.AvailabilityReq availability, string curr, string src) { CheckAvailabilityResult availabilityResult = new CheckAvailabilityResult(); availabilityResult = AvailabilityManager.checkAvailabilityManager(availability, curr, src); return(availabilityResult); }
public void TestDectivateAvailabilitesInvalidID() { //Arrange IAvailabilityManager _availabilityManager = new AvailabilityManager(_availabilityAccessor); //Act var actualResult = _availabilityManager.DeactivateAvailability(10); }
public void TestRetrieveAvailabilitesInvalidUserID() { //Arrange IAvailabilityManager _availabilityManager = new AvailabilityManager(_availabilityAccessor); //Act var actualResult = _availabilityManager.RetrieveAvailabilityByUserID(0); }
public void TestInsertAvailabilityInvalidAvailabilityEndTimeTooLong() { //Arrange EmployeeAvailability availability = new EmployeeAvailability() { AvailabilityID = 4, DayOfWeek = "Monday", StartTime = "22:00", EndTime = "12345677889132456789132", EmployeeID = 1 }; IAvailabilityManager _availabilityManager = new AvailabilityManager(_availabilityAccessor); //Act bool actualResult = _availabilityManager.AddAvailability(availability); }
public void TestInsertAvailabilityInvalidUserID() { //Arrange EmployeeAvailability availability = new EmployeeAvailability() { AvailabilityID = 4, DayOfWeek = "Monday", StartTime = "22:00", EndTime = "24:00", EmployeeID = 0 }; IAvailabilityManager _availabilityManager = new AvailabilityManager(_availabilityAccessor); //Act bool actualResult = _availabilityManager.AddAvailability(availability); }
public void TestDeactivateAvailabilites() { //Arrange bool expectedResult = true; IAvailabilityManager _availabilityManager = new AvailabilityManager(_availabilityAccessor); //Act var actualResult = _availabilityManager.DeactivateAvailability(1); //Assert Assert.AreEqual(expectedResult, actualResult); }
public void TestRetrieveAvailabilitesByUserID() { //Arrange int expectedResult = 3; IAvailabilityManager _availabilityManager = new AvailabilityManager(_availabilityAccessor); //Act var actualResult = _availabilityManager.RetrieveAvailabilityByUserID(100000); //Assert Assert.AreEqual(expectedResult, actualResult.Count); }
public void TestUpdateOldAvailabilityNotReal() { //Arrange EmployeeAvailability oldAvailability = new EmployeeAvailability() { AvailabilityID = 1, DayOfWeek = "NoDay", StartTime = "10:00", EndTime = "18:00", EmployeeID = 1 }; EmployeeAvailability availability = new EmployeeAvailability() { AvailabilityID = 1, DayOfWeek = "Monday", StartTime = "10:00", EndTime = "18:00", EmployeeID = 1 }; IAvailabilityManager _availabilityManager = new AvailabilityManager(_availabilityAccessor); bool actualResult = _availabilityManager.EditAvailability(availability, oldAvailability); }
public void TestInsertAvailabilitySuccess() { //Arrange EmployeeAvailability availability = new EmployeeAvailability() { AvailabilityID = 5, DayOfWeek = "Monday", StartTime = "22:00", EndTime = "24:00", EmployeeID = 100001 }; IAvailabilityManager _availabilityManager = new AvailabilityManager(_availabilityAccessor); bool expectResult = true; //Act bool actualResult = _availabilityManager.AddAvailability(availability); //Assert Assert.AreEqual(expectResult, actualResult); }
public void TestUpdateNewAvailabilityInvalidAvailabilityStartTimeTooLong() { //Arrange EmployeeAvailability oldAvailability = new EmployeeAvailability() { AvailabilityID = 1, DayOfWeek = "Monday", StartTime = "10:00", EndTime = "18:00", EmployeeID = 1 }; EmployeeAvailability availability = new EmployeeAvailability() { AvailabilityID = 1, DayOfWeek = "Monday", StartTime = "12345678913245678789132", EndTime = "24:00", EmployeeID = 1 }; IAvailabilityManager _availabilityManager = new AvailabilityManager(_availabilityAccessor); //Act bool actualResult = _availabilityManager.EditAvailability(availability, oldAvailability); }
public ActionResult Add(AvailabilityFormViewModel availabilityModel) { if (!ModelState.IsValid) { return(View("AvailabilityForm", availabilityModel)); } var accommodationAvailability = _db.Availabilities.Where(a => a.AccommodationId == availabilityModel.AccommodationId).ToList(); var accommodationBookings = _db.Bookings.Where(b => b.AccommodationId == availabilityModel.AccommodationId).ToList(); foreach (var booking in accommodationBookings) { if (availabilityModel.OccupationStart <= booking.Departure && availabilityModel.OccupationEnd >= booking.Arrival) { return(View()); } } foreach (var availability in accommodationAvailability) { if (availabilityModel.OccupationStart > availability.AvailabilityStart && availabilityModel.OccupationEnd < availability.AvailabilityEnd) { AvailabilityManager.AvailabilityDivision(availabilityModel, availability); break; } else { return(View()); } } return(RedirectToAction("Index", "Availability")); }