void btnInsertBookingEquipment_Click(object sender, RoutedEventArgs e) { RoomEquipment equipment = uiEquipmentList.SelectedItem as RoomEquipment; if (equipment != null && _selectedBookingId > 0) { List <BookingRoomEquipment> list = (List <BookingRoomEquipment>)gvwBookingEquipment.ItemsSource; if (list.Count(i => i.EquipmentId == equipment.EquipmentId) > 0) { MessageBox.Show(ResourceHelper.GetReourceValue("Common_ItemExist")); } else { BookingRoomEquipment newBookingEquipment = new BookingRoomEquipment(); newBookingEquipment.BookingId = _selectedBookingId; newBookingEquipment.EquipmentId = equipment.EquipmentId; newBookingEquipment.Equipment = equipment.Equipment; newBookingEquipment.IsChanged = true; newBookingEquipment.Price = equipment.Price; newBookingEquipment.Unit = equipment.Unit; newBookingEquipment.Description = equipment.Description; list.Add(newBookingEquipment); gvwBookingEquipment.ItemsSource = null; gvwBookingEquipment.ItemsSource = list; } } }
/// <summary> /// Creates new record in RoomEquipment table. /// If the room name is not found, the exception will be thrown. /// If the equipment name is not found, it will be added. /// </summary> /// <param name="item"></param> /// <returns></returns> private async Task AddEquipmentItem(EquipmentModel item) { //find room by name var room = await context.Rooms .Include(e => e.Building) .FirstOrDefaultAsync(x => $"{x.Floor}.{x.Building.Number}/{x.Number}".Equals(item.RoomName)) ?? throw new NotFoundException(typeof(Room), item.RoomName); // find equipment by name var equipment = await context.Equipment.FirstOrDefaultAsync(x => x.Name == item.EquipmentName); // If the equipment does not exist, create a new one. if (equipment == null) { equipment = mapper.Map <Equipment>(item); context.Equipment.Add(equipment); } var roomEquipment = new RoomEquipment() { Amount = item.Amount, Equipment = equipment, Room = room, IsAvailable = true, }; context.RoomEquipment.Add(roomEquipment); }
public void Initialize(RoomEquipment roomEquipment) { this.Id = roomEquipment.Equipment.Id; this.Title = roomEquipment.Equipment.Title; this.Number = roomEquipment.EquipmentNumber; this.RoomId = roomEquipment.RoomId; }
void roomEquipment_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (e.PropertyName != "IsChanged") { RoomEquipment item = (RoomEquipment)sender; item.IsChanged = true; } }
private void ListView_Drop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent("myFormat")) { EquipmentDTO equip = e.Data.GetData("myFormat") as EquipmentDTO; Inventory.Remove(equip); RoomEquipment.Add(equip); Moved.Add(equip); } }