public override int?Save(string action) { var data = new ClientDataModel(); data.ClientId = SystemKeyId; data.Name = Name; data.Description = Description; data.SortOrder = SortOrder; if (action == "Insert") { var dtClient = ClientDataManager.DoesExist(data, SessionVariables.RequestProfile); if (dtClient.Rows.Count == 0) { ClientDataManager.Create(data, SessionVariables.RequestProfile); } else { throw new Exception("Record with given ID already exists."); } } else { ClientDataManager.Update(data, SessionVariables.RequestProfile); } // not correct ... when doing insert, we didn't get/change the value of ClientID ? return(data.ClientId); }