Пример #1
0
        public CoffeeBreak Read(string numContrato)
        {
            OnBreakDBEntities db          = new OnBreakDBEntities();
            CoffeeBreak       coffeeBreak = (from c in db.CoffeeBreak
                                             where c.Numero == numContrato
                                             select new CoffeeBreak
            {
                Contrato = new Contrato()
                {
                    Numero = c.Numero
                },
                Vegetariana = c.Vegetariana
            }).FirstOrDefault();

            return(coffeeBreak);
        }
Пример #2
0
        public bool Create(CoffeeBreak coffeeBreak)
        {
            OnBreakDBEntities db     = new OnBreakDBEntities();
            CoffeeBreak       coffee = new CoffeeBreak();

            try
            {
                Datos.CoffeeBreak c = new Datos.CoffeeBreak();
                c.Numero      = coffeeBreak.Contrato.Numero;
                c.Vegetariana = coffeeBreak.Vegetariana;

                db.CoffeeBreak.Add(c);
                db.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Пример #3
0
        public bool Update(CoffeeBreak coffeeBreak)
        {
            OnBreakDBEntities db = new OnBreakDBEntities();

            try
            {
                Datos.CoffeeBreak c = (from cb in db.CoffeeBreak
                                       where cb.Numero == coffeeBreak.Contrato.Numero
                                       select cb).FirstOrDefault();

                c.Vegetariana = coffeeBreak.Vegetariana;

                db.Entry(c).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }