Example #1
0
 public VegPlotType GetPlotType(CompoundIdentity id)
 {
     if (!id.IsNullOrEmpty() && Db.DataStoreIdentity.Equals(id.DataStoreIdentity) && this.CanGet())
     {
         NpgsqlCommand cmd = Db.GetCmd(Db.ConnectionString);
         cmd.CommandText = Db.SelectPlotType + Db.Where + Db.WhereId;
         cmd.Parameters.AddWithValue("id", id.Identity);
         NpgsqlDataReader rdr = Db.ExecuteReader(cmd);
         VegPlotType      o   = null;
         if (rdr != null)
         {
             try
             {
                 rdr.Read();
                 o = this.plotBuilder.Build(rdr);
                 if (cmd.Connection.State == System.Data.ConnectionState.Open)
                 {
                     cmd.Connection.Close();
                 }
             }
             catch
             { }
             finally
             {
                 cmd.Dispose();
             }
         }
         return(o);
     }
     return(null);
 }
Example #2
0
 public bool CanDelete(VegPlotType item)
 {
     if (item != null && Db.DataStoreIdentity.Equals(item.Identity.DataStoreIdentity))
     {
         return(this.CanDelete());
     }
     return(false);
 }
Example #3
0
        public bool DeletePlotType(CompoundIdentity id)
        {
            VegPlotType tmp = this.GetPlotType(id);

            if (tmp != null)
            {
                return(Delete(tmp));
            }
            return(false);
        }
Example #4
0
 public static JObject ToJson(VegPlotType plot)
 {
     if (plot != null)
     {
         JObject o = new JObject();
         o.Add(JsonUtils.Id, JsonUtils.ToJson(plot.Identity));
         o.Add(JsonUtils.Name, plot.Name);
         if (plot.Description != null)
         {
             o.Add(JsonUtils.Description, plot.Description);
         }
         return(o);
     }
     return(null);
 }
Example #5
0
 public bool Delete(VegPlotType item)
 {
     if (item != null && this.CanDelete(item))
     {
         try
         {
             NpgsqlCommand cmd = Db.GetCmd(Db.ConnectionString);
             cmd.CommandText = Db.DeletePlotType;
             cmd.Parameters.AddWithValue("id", item.Identity.Identity);
             Db.ExecuteNonQuery(cmd);
             return(true);
         }
         catch
         { }
     }
     return(false);
 }