public ActionResult Create() { List <RoomCategoryModel> categoryroom = _roomService.GetAllRoomCategories(); List <FacilityModel> facilities = _facilityService.GetAllFacilities(); var model = new RoomCategoriesViewModel(); model.RoomCategories = categoryroom; model.facilities = facilities; return(View(model)); }
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 ActionResult Create(RoomCategoriesViewModel model) { if (ModelState.IsValid) { if (_roomService.IsValidRoomName(model.Room.RoomName, "")) { List <RoomCategoryModel> categoryroom = _roomService.GetAllRoomCategories(); model.RoomCategories = categoryroom; int categoryid = model.RCModel.Id; if (model.Room.ImageFile != null) { string filename = Path.GetFileNameWithoutExtension(model.Room.ImageFile.FileName); string extention = Path.GetExtension(model.Room.ImageFile.FileName); if (string.Equals(extention, ".jpg", StringComparison.OrdinalIgnoreCase) || string.Equals(extention, ".png", StringComparison.OrdinalIgnoreCase) || string.Equals(extention, ".gif", StringComparison.OrdinalIgnoreCase) || string.Equals(extention, ".jpeg", StringComparison.OrdinalIgnoreCase)) { filename = filename + DateTime.Now.ToString("yymmssfff") + extention; model.Room.ImagePath = "~/Images/" + filename; filename = Path.Combine(Server.MapPath("~/Images/"), filename); model.Room.ImageFile.SaveAs(filename); _roomService.CreateNewRoom(model.Room.RoomName, model.Room.RoomDescription, model.Room.GuestsNr, model.Room.Price, model.Room.ImagePath, categoryid); ViewBag.Added = "Room added successfully"; } else { ViewBag.ImageError = "The uploaded file should only be an image of type .jpg or .png or .gif or .jpeg"; } } } else { ViewBag.Message = "The is already a room with the same name"; } } else { List <RoomCategoryModel> categoryroom = _roomService.GetAllRoomCategories(); model.RoomCategories = categoryroom; return(View(model)); } List <RoomCategoryModel> categoryroom1 = _roomService.GetAllRoomCategories(); model.RoomCategories = categoryroom1; return(View(model)); }