public bool Save(risTabulky risContext) { bool success = false; try { if (id_typu == 0) // INSERT { this.FillEntity(); risContext.typ_napoja.Add(entityTypNapoja); risContext.SaveChanges(); id_typu = entityTypNapoja.id_typu; success = true; } else // UPDATE { var temp = from a in risContext.typ_napoja where a.id_typu == id_typu select a; entityTypNapoja = temp.Single(); this.FillEntity(); risContext.SaveChanges(); success = true; } } catch (Exception ex) { throw new ApplicationException(String.Format("{0}.{1}", this.GetType(), "Save()"), ex); } return(success); }
private void Reset() { id_typu = 0; text_id = 0; text = new BText(); napoj = new List <BNapoj>(); entityTypNapoja = new typ_napoja(); }
public BTyp_napoja(typ_napoja tn) { id_typu = tn.id_typu; text_id = tn.text_id; text = new BText(tn.text); napoj = new List <BNapoj>(); foreach (var napoj1 in tn.napoj) { BNapoj pom = new BNapoj(napoj1); napoj.Add(pom); } entityTypNapoja = tn; }
public bool Get(risTabulky risContext, int id) { bool success = false; try { var temp = from a in risContext.typ_napoja where a.id_typu == id select a; entityTypNapoja = temp.Single(); this.FillBObject(); success = true; } catch (Exception ex) { throw new ApplicationException(String.Format("{0}.{1}", this.GetType(), "Get()"), ex); } return(success); }