public async Task <bool> AddRoomCategoryAsync(RoomCategoryModel roomCategoryModel) { _context.RoomCategory.Add(roomCategoryModel); var saveResult = await _context.SaveChangesAsync(); return(saveResult == 1); }
public IEnumerable <RoomCategoryModel> GetRoomCategories() { var listCategoryRoom = new List <RoomCategoryModel>(); var tableRows = _htmlDocument.DocumentNode.SelectNodes("//table[@id=\"maxotel_rooms\"]//tbody//tr"); foreach (var row in tableRows) { var tableCells = row.Descendants("td").ToArray(); var cellCapacity = tableCells[0].Descendants("i").FirstOrDefault(); var strCapacity = cellCapacity.GetAttributeValue("title", "n/a"); var capacity = int.Parse(strCapacity.Replace("Standard occupancy:", string.Empty).Trim()); var plusKid = tableCells[0].Descendants("span").Where(c => c.HasClass("plus_kids")).FirstOrDefault() != null; var roomType = tableCells[1].InnerText.Replace("\n", string.Empty); var roomCategory = new RoomCategoryModel { Capacity = capacity, PlusKid = plusKid, RoomType = roomType }; listCategoryRoom.Add(roomCategory); } return(listCategoryRoom); }
public static RoomCategoryModel MappRcViewModelToRoomCategoriesModel(RoomCategoriesViewModel rcviewmodel) { var rcmodel = new RoomCategoryModel { Id = rcviewmodel.RCModel.Id, CatName = rcviewmodel.RCModel.CatName, Description = rcviewmodel.RCModel.Description, }; return(rcmodel); }
public static RoomCategoryModel MapRoomCatToRCModel(RoomCategory RoomCat) { var Cat = new RoomCategoryModel { Id = RoomCat.Id, CatName = RoomCat.Name, Description = RoomCat.Description }; return(Cat); }
public static RoomCategoryModel MapRoomCategoryToRCModel(RoomCategory RoomCat) { var Cat = new RoomCategoryModel { Id = RoomCat.Id, CatName = RoomCat.Name, Description = RoomCat.Description }; Cat.Rooms = RoomCat.Rooms.Select(r => MapRoomToRoomModel(r, Cat)).ToList(); return(Cat); }
public static RoomCategory MApRcToRoomCategory(RoomCategoryModel RoomCatModel) { var Cat = new RoomCategory { Id = RoomCatModel.Id, Name = RoomCatModel.CatName, Description = RoomCatModel.Description }; Cat.Rooms = RoomCatModel.Rooms.Select(r => MapRoomModelToRom(r)).ToList(); return(Cat); }
public static RoomModel MapRoomToRoomModel(Room room, RoomCategoryModel CatModel) { var roomModel = new RoomModel { Id = room.Id, Active = room.Enabled, Occupied = room.Occupied, GuestsNr = room.NrOfGuests, Price = room.Price, RoomName = room.Name, CategoryId = room.CategoryId, RoomCategory = CatModel, RoomDescription = room.Description }; roomModel.BookingRooms = room.BookingRooms.Select(b => BookingMappings.MapBookingRoomToBookingRoomModel(b, null, null)).ToList(); roomModel.RoomFacilities = room.RoomFacilities.Select(rf => FacilityMappings. MapRoomFacilityToRFModel(rf, roomModel, FacilityMappings.MapFacilityToFacilityModel(rf.Facility))).ToList(); return(roomModel); }
public async Task <IActionResult> AddRoomCategory(RoomCategoryBindingModel roomCategoryBindingModel) { // Check that the binding model is valid. if (!ModelState.IsValid) { return(RedirectToAction("Index")); } // If that's the case, create a model from the binding model. var roomCategoryModel = new RoomCategoryModel { Description = roomCategoryBindingModel.Description, MaxCapacity = roomCategoryBindingModel.MaxCapacity }; var successful = await _roomCategoryService.AddRoomCategoryAsync(roomCategoryModel); if (!successful) { return(BadRequest("Could not add the room category.")); } return(RedirectToAction("Index")); }