public int NextId(string type) { int id = 1; if (type == "consumable" || type == "other") { var items = new ItemDataAccess().FindAll <Item>(); if (items.Count != 0) { id = items.OrderBy(x => x.Id).Last().Id + 1; } } else { var equipments = new EquipmentDataAccess().FindAll <Equipment>(); if (equipments.Count != 0) { id = equipments.OrderBy(x => x.Id).Last().Id + 1; } } return(id); }