private void btnAddCopy_Click(object sender, EventArgs e) { if (ValidateChildren(ValidationConstraints.Enabled)) { List <Location> availableLocation = WebApiClient.GetAvailableLocation(); if (availableLocation.Where(x => x.Shelf.Equals((int)numShelve.Value) && x.ShelfCol.Equals((int)numCol.Value) && x.ShelfRow.Equals((int)numRow.Value)).SingleOrDefault() != null) { Copy copy = new Copy(); copy.RFID = txtRFID.Text; copy.Status = new Status(); copy.Status.Name = "Available"; copy.Book = new Book(); copy.Book.BookId = int.Parse((cbBookTitle.SelectedItem as ComboBoxItem).Value.ToString()); copy.Location = new Location() { Shelf = (int)numShelve.Value, ShelfRow = (int)numRow.Value, ShelfCol = (int)numCol.Value }; if (WebApiClient.AddCopy(copy)) { MessageBox.Show("Copy has been added."); if (!this.DesignMode) { list = GetPagedListAsync(); btnPrevious.Enabled = list.HasPreviousPage; btnNext.Enabled = list.HasNextPage; dgCopyLocation.DataSource = list.Select(o => new { Shelve = o.Shelf, Row = o.ShelfRow, Column = o.ShelfCol }).ToList(); lblPageCount.Text = string.Format("Page {0}/{1}", pageNumber, list.PageCount); } } } else { MessageBox.Show("That location is not available. Please select a different location from the grid table."); } } }