private void ChangeArea() { Model.Room room = roomController.GetByIdRoom(int.Parse(renovationSeparation.cbRooms.SelectedItem.ToString())); room.Area -= double.Parse(tbuArea.Text); roomController.UpdateRoom(room.RoomId, room.Description, room.Area, room.RoomType); renovationSeparation.LoadArea(); }
internal void EditRoom() { int roomCount = roomController.RoomCount(); if (roomCount > 0) { Console.WriteLine("Please enter only one room name as displayed below"); DisplayRoom(); Console.Write("> "); var roomNameToChange = Console.ReadLine(); while (roomController.SearchRoom(roomNameToChange) == null) { Console.WriteLine("Sorry! The room you wanna edit does not exist. Try again!"); Console.Write("> "); roomNameToChange = Console.ReadLine(); } Room oldRoom = roomController.SearchRoom(roomNameToChange); Console.Write("You will change old name \"{0}\" to new name or press [Enter] to unchange: ", oldRoom.RoomNo); string updatedName = Console.ReadLine(); if (updatedName == "") { updatedName = oldRoom.RoomNo; } // Keep old name of room to modify if it happens error during updating string name = oldRoom.RoomNo; // Delete course to edit by its id roomController.DeleteRoom(roomNameToChange); if (roomController.UpdateRoom(updatedName)) { Console.WriteLine("You updated new information for room name: " + updatedName); } else { // this condition will run if update name duplicate with other room name roomController.CreateRoom(name); Console.WriteLine("You failed to update new information for room name: " + name); Console.WriteLine(); } } else { Console.WriteLine("Opp! empty room list. You should use selection 1 to add a room."); } Console.WriteLine("Press[Enter] button to continue..."); Console.ReadLine(); }