public async Task <IActionResult> Edit(Guid id, [Bind("Id,Number,Price,Type")] RoomViewModels roomViewModels) { var room = roomViewModels.ToEntity(); if (id != room.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(room); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RoomViewModelsExists(room.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(room.ToViewModel())); }
private void onRoomStatesChanged(RaumFeldEvent args) { // val = "uuid:29e07ad9-224f-4160-a2bc-61d17845182a=PLAYING" /> string[] stringSeparators = new string[] { "=", "," }; string[] splitValue = new string[0]; if (args.ChangedValues.TryGetValue("val", out string roomstates)) { splitValue = roomstates.Split(stringSeparators, StringSplitOptions.RemoveEmptyEntries); if ((RoomViewModels?.Count() ?? 0) == 0 || (splitValue?.Count() ?? 0) == 0) { return; } IRoomViewModel room = RoomViewModels.Select(r => r).Where(r => r.Udn == splitValue[0]).FirstOrDefault(); if (room != null) { switch (splitValue[1]) { case "PLAYING": break; case "STOPPED": break; case "TRANSITIONING": break; default: break; } } } }
public async Task <IActionResult> Create([Bind("Id,Number,Price,Type")] RoomViewModels roomViewModels) { var room = roomViewModels.ToEntity(); if (ModelState.IsValid) { room.Id = Guid.NewGuid(); _context.Add(room); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(room.ToViewModel())); }
public static RoomModel MappRcViewModelToRoomModel(RoomViewModels rviewmodel) { var rmodel = new RoomModel { Id = rviewmodel.Id, GuestsNr = rviewmodel.NrOfGuests, RoomName = rviewmodel.RoomName, ImagePath = rviewmodel.ImagePath, RoomDescription = rviewmodel.RoomDescription, Price = rviewmodel.Price, CategoryId = rviewmodel.CategoryId, }; return(rmodel); }
public static RoomViewModels MapRoomModelToRoomViewModel(RoomModel rmodel) { var rvmodel = new RoomViewModels() { Id = rmodel.Id, RoomName = rmodel.RoomName, RoomDescription = rmodel.RoomDescription, NrOfGuests = rmodel.GuestsNr, Price = rmodel.Price, ImagePath = rmodel.ImagePath, ImageFile = rmodel.ImageFile, CategoryId = rmodel.CategoryId }; return(rvmodel); }
public ActionResult EditRooms(int id) { List <RoomCategoryModel> categoryroom = _roomService.GetAllRoomCategories(); var model = new RoomViewModels(); var room = _roomService.GetRoomById(id); string filename = _roomService.GetFilePath(id); model.RoomCategories = categoryroom; model.RoomName = room.RoomName; model.ImagePath = filename; model.NrOfGuests = room.GuestsNr; model.RoomDescription = room.RoomDescription; model.CategoryId = room.CategoryId; model.Price = room.Price; TempData["imgpath"] = filename; TempData["roomname"] = room.RoomName; return(View(model)); }
private void onRoomVolumesChanged(RaumFeldEvent args) { //val = "uuid:29e07ad9-224f-4160-a2bc-61d17845182a=100" /> string[] stringSeparators = new string[] { "=", "," }; string[] splitValue = new string[0]; if (args.ChangedValues.TryGetValue("val", out string volume)) { // Split delimited by another string and return all non-empty elements. splitValue = volume.Split(stringSeparators, StringSplitOptions.RemoveEmptyEntries); if ((RoomViewModels?.Count() ?? 0) == 0) { return; } IRoomViewModel room = RoomViewModels.Select(r => r).Where(r => r.Udn == splitValue[0]).FirstOrDefault(); if (room != null) { room.RoomVolume = double.Parse(splitValue[1]); } } }
public ActionResult EditRooms(RoomViewModels rvmodel, HttpPostedFileBase file) { if (ModelState.IsValid) { List <RoomCategoryModel> categoryroom = _roomService.GetAllRoomCategories(); rvmodel.RoomCategories = categoryroom; if (_roomService.IsValidRoomName(rvmodel.RoomName, TempData["roomname"].ToString())) { if (file != null) { string filename = Path.GetFileNameWithoutExtension(file.FileName); string extention = Path.GetExtension(file.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; rvmodel.ImagePath = "~/Images/" + filename; filename = Path.Combine(Server.MapPath("~/Images/"), filename); file.SaveAs(filename); var roomModel = RoomCategoriesViewModelMappings.MappRcViewModelToRoomModel(rvmodel); _roomService.UpdateRoom(roomModel); } else { ViewBag.ErrorMessage = "The uploaded file must be .jpg or .png or .jpeg or .gif"; List <RoomCategoryModel> categoryroom1 = _roomService.GetAllRoomCategories(); var model = new RoomViewModels(); var room = _roomService.GetRoomById(rvmodel.Id); filename = _roomService.GetFilePath(rvmodel.Id); model.RoomCategories = categoryroom1; model.RoomName = room.RoomName; model.ImagePath = filename; model.NrOfGuests = room.GuestsNr; model.RoomDescription = room.RoomDescription; model.CategoryId = room.CategoryId; model.Price = room.Price; TempData["imgpath"] = filename; TempData["roomname"] = room.RoomName; return(View(model)); } } else { rvmodel.ImagePath = TempData["imgpath"].ToString(); var roomModel = RoomCategoriesViewModelMappings.MappRcViewModelToRoomModel(rvmodel); _roomService.UpdateRoom(roomModel); ViewBag.Message = "Room Updated Successfully"; } } else { ViewBag.ErrorMessage = "The is already a room with this name"; List <RoomCategoryModel> categoryroom1 = _roomService.GetAllRoomCategories(); var model = new RoomViewModels(); var room = _roomService.GetRoomById(rvmodel.Id); string filename = _roomService.GetFilePath(rvmodel.Id); model.RoomCategories = categoryroom1; model.RoomName = room.RoomName; model.ImagePath = filename; model.NrOfGuests = room.GuestsNr; model.RoomDescription = room.RoomDescription; model.CategoryId = room.CategoryId; model.Price = room.Price; TempData["imgpath"] = filename; TempData["roomname"] = room.RoomName; return(View(model)); } } else { List <RoomCategoryModel> categoryroom1 = _roomService.GetAllRoomCategories(); var model = new RoomViewModels(); var room = _roomService.GetRoomById(rvmodel.Id); string filename = _roomService.GetFilePath(rvmodel.Id); model.RoomCategories = categoryroom1; model.RoomName = room.RoomName; model.ImagePath = filename; model.NrOfGuests = room.GuestsNr; model.RoomDescription = room.RoomDescription; model.CategoryId = room.CategoryId; model.Price = room.Price; TempData["imgpath"] = filename; TempData["roomname"] = room.RoomName; return(View(model)); } return(Redirect("http://localhost:18216/Rooms/ShowAllRooms")); }