public async void Initialize() { RenovationEndDate = RenovationStartDate = null; RenovationStartTime = RenovationEndTime = null; SplittingRoom = false; OtherRenovations = false; AddedEquipmentTypes.Clear(); RemovedEquipmentTypes.Clear(); EquipmentTypesInRoom.Clear(); FreeEquipmentTypes.Clear(); await LoadRooms(); }
// Used by Fody weaver private void OnCurrentlySelectedRoomChanged() { if (CurrentlySelectedRoom is null) { return; } RoomTypes = new ObservableCollection <RoomType>(Enum.GetValues(typeof(RoomType)).Cast <RoomType>().ToList()); RoomTypes.Remove(RoomTypes.First(rt => rt == CurrentlySelectedRoom.Type)); LoadCurrentCalendarWeekForRoom(); ExecuteLoadRoomsAvailableToJoinTo(); AddedEquipmentTypes.Clear(); RemovedEquipmentTypes.Clear(); LoadFreeEquipmentTypes(); LoadRoomEquipmentTypes(); }
private async void ExecuteScheduleRenovation() { RoomAlreadyInUse = InvalidTimeFrame = false; var renovationStartPeriod = RenovationStartDate + RenovationStartTime?.TimeOfDay; var renovationEndPeriod = RenovationEndDate + RenovationEndTime?.TimeOfDay; if (renovationEndPeriod <= renovationStartPeriod || renovationStartPeriod == null || renovationEndPeriod == null) { InvalidTimeFrame = true; return; } // Trying to save some RAM if ((await _calendarEntryService.GetAllByRoomAndTimeFrame(CurrentlySelectedRoom.Room, renovationStartPeriod.Value, renovationEndPeriod.Value)).Count != 0) { RoomAlreadyInUse = true; return; } var addedItems = await AddedEquipmentItems(); var removedItems = await RemovedEquipmentItems(); var roomToJoinTo = RoomToJoinTo?.Room; await _renovationService.Create(CurrentlySelectedRoom.Room, roomToJoinTo, NewRoomType, renovationStartPeriod.Value, renovationEndPeriod.Value, SplittingRoom, removedItems, addedItems); if (removedItems.Count > 0) { foreach (var equipmentItem in removedItems) { await _equipmentItemService.Create(equipmentItem.EquipmentType, 1); } } Calendar.AddEvents((await _calendarEntryService.GetAllByRoomAndTimeFrame(CurrentlySelectedRoom.Room, renovationStartPeriod.Value, renovationEndPeriod.Value)).ToList()); RenovationEndDate = RenovationStartDate = RenovationStartTime = RenovationEndTime = null; SplittingRoom = false; OtherRenovations = false; AddedEquipmentTypes.Clear(); RemovedEquipmentTypes.Clear(); LoadFreeEquipmentTypes(); LoadRoomEquipmentTypes(); }