Пример #1
0
        public bool Del(risTabulky risContext)
        {
            bool success = false;

            try
            {
                var temp = risContext.jedlo_surovina.First(i => i.id_jedla == id_jedla && i.id_surovina == id_surovina);
                risContext.jedlo_surovina.Remove(temp);
                risContext.SaveChanges();
                success = true;
                this.Reset();
            }
            catch (Exception ex)
            {
                throw new ApplicationException(String.Format("{0}.{1}", this.GetType(), "Del()"), ex);
            }

            return success;
        }
Пример #2
0
        public bool Save(risTabulky risContext)
        {
            bool success = false;

            try
            {
                if (id_jedla == -1 && id_surovina == -1) // INSERT
                {
                    this.FillEntity();
                    risContext.jedlo_surovina.Add(entityJedloSurovina);
                    risContext.SaveChanges();
                    this.FillBObject();
                    success = true;
                }
                else // UPDATE
                {
                    var temp = from a in risContext.jedlo_surovina where a.id_jedla == id_jedla && a.id_surovina==id_surovina select a;
                    entityJedloSurovina = temp.Single();
                    this.FillEntity();
                    risContext.SaveChanges();

                    success = true;
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException(String.Format("{0}.{1}", this.GetType(), "Save()"), ex);
            }

            return success;
        }