public async Task <IActionResult> DeleteConfirmed(int?id) { if (id == null) { return(NotFound()); } ResultObject resultObj; try { if (_cache.TryGetValue("CACHE_MASTER_WAREHOUSE", out List <M_Warehouse> c_lstWh)) { var m_Warehouse = c_lstWh.Find(w => w.Id == id); if (m_Warehouse == null) { return(NotFound()); } m_Warehouse.Updated_By = await base.CurrentUserId(); using (var whBll = new WarehouseBLL()) { resultObj = await whBll.DeleteWarehouse(m_Warehouse); _cache.Remove("CACHE_MASTER_WAREHOUSE"); } return(Json(new { success = true, data = (M_Warehouse)resultObj.ObjectValue, message = "Warehouse Deleted." })); } using (var whBll = new WarehouseBLL()) { var lstWh = await whBll.GetWarehouse(id); var m_Warehouse = lstWh.First(); if (m_Warehouse == null) { return(NotFound()); } m_Warehouse.Updated_By = await base.CurrentUserId(); resultObj = await whBll.DeleteWarehouse(m_Warehouse); _cache.Remove("CACHE_MASTER_WAREHOUSE"); } return(Json(new { success = true, data = (M_Warehouse)resultObj.ObjectValue, message = "Warehouse Deleted." })); } catch (Exception ex) { return(Json(new { success = false, message = ex.Message })); } }