public bool Delete(string shelfCode) { var shelf = ShelfRepository.GetQueryable() .FirstOrDefault(s => s.ShelfCode == shelfCode); if (shelf != null) { //Del(CellRepository, shelf.Cells); ShelfRepository.Delete(shelf); ShelfRepository.SaveChanges(); } else { return(false); } return(true); }
protected void ShelfGridView_RowDeleting(object sender, GridViewDeleteEventArgs e) { try { Shelfs _Shelfs = new Shelfs(); _Shelfs.Name = ShelfGridView.DataKeys[e.RowIndex].Value.ToString(); int deletesuccess = _ShelfRepository.Delete(_Shelfs); if (deletesuccess > 0) { LoadShelfs(); lblmsg.Text = "Successefully Delete Shelfs!!...."; lblmsg.ForeColor = Color.Green; } } catch (Exception ex) { lblmsg.Text = ex.Message; lblmsg.ForeColor = Color.Red; } }