public override FieldTeamMemberRole Get(CompoundIdentity id) { if (!id.IsNullOrEmpty() && this.CanGet()) { NpgsqlCommand cmd = Db.GetCmd(Db.ConnectionString); cmd.CommandText = Db.SelectFTMRoles + Db.SelectById; cmd.Parameters.AddWithValue("sid", id.DataStoreIdentity); cmd.Parameters.AddWithValue("id", id.Identity); NpgsqlDataReader rdr = Db.ExecuteReader(cmd); FieldTeamMemberRole o = null; if (rdr != null) { try { rdr.Read(); o = FieldTeamMemberRoleBuilder.Instance.Build(rdr); if (cmd.Connection.State == System.Data.ConnectionState.Open) { cmd.Connection.Close(); } } catch { } finally { cmd.Dispose(); } } return(o); } return(null); }
public override bool Update(FieldTeamMemberRole item) { if (item != null && this.CanUpdate(item)) { try { NpgsqlCommand cmd = Db.GetCmd(Db.ConnectionString); cmd.CommandText = Db.UpdateFTMRole; cmd.Parameters.AddWithValue("sid", item.Identity.DataStoreIdentity); cmd.Parameters.AddWithValue("id", item.Identity.Identity); cmd.Parameters.AddWithValue("name", item.Name); cmd.Parameters.AddWithValue("desc", item.Description); Db.ExecuteNonQuery(cmd); return(true); } catch { } } return(false); }
public override bool CanUpdate(FieldTeamMemberRole item) { return(this.CanUpdate()); //TODO -- add fine grained security }