Exemple #1
0
 internal PgFishProvider(UserSecurityContext context)
 {
     this.Context     = context;
     this.fishBuilder = new FishBuilder(context);
     this.dietBuilder = new FishDietBuilder(context, this);
     this.genBuilder  = new FishGeneticsBuilder(context, this);
     this.idBuilder   = new FishIdTagBuilder(context, this);
 }
Exemple #2
0
        public FishGenetics CreateFishGenetics(Guid fishId, string geneticSampleId, string labSampleId, StockEstimates estimates, string description)
        {
            if (!Guid.Empty.Equals(fishId) && estimates != null && this.CanCreate())
            {
                try
                {
                    Guid          id  = Guid.NewGuid();
                    NpgsqlCommand cmd = Db.GetCmd(Db.ConnectionString);
                    cmd.CommandText = Db.InsertFishGenetics;
                    cmd.Parameters.AddWithValue("id", id);
                    cmd.Parameters.AddWithValue("fid", fishId);
                    Db.AddParam(cmd, "gen", geneticSampleId);
                    Db.AddParam(cmd, "lab", labSampleId);
                    cmd.Parameters.AddWithValue("stock", FishGeneticsBuilder.Encode(estimates)); //stringifies the estimates
                    Db.AddParam(cmd, "d", description);
                    Db.ExecuteNonQuery(cmd);

                    return(new FishGenetics(id, fishId, geneticSampleId, labSampleId, estimates, description));
                }
                catch
                { }
            }
            return(null);
        }