Exemplo n.º 1
0
        public bool UpdateCompanii(int id_com, string an_studiu, int code)
        {
            if (code == 0)
                return false;
            using (var transaction = context.Database.BeginTransaction())
            {
                try
                {
                    var c = new Companii
                    {
                        ID_com = id_com,
                        An_studii = an_studiu,
                    };
                    context.Companiis.Attach(c);
                    context.Entry(c).State = System.Data.Entity.EntityState.Modified;
                    context.SaveChanges();
                    transaction.Commit();
                    return true;

                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    return false;
                }
            }
        }
Exemplo n.º 2
0
        public bool InsertCompanii(int id_com, string an_studiu, int code)
        {
            if (code == 0)
                return false;
            using (var context = new ServiciiATMContext())
            {
                var com = new Companii
                {
                    ID_com = id_com,
                    An_studii = an_studiu,
                };
                context.Companiis.Add(com);
                context.Entry(com).State = System.Data.Entity.EntityState.Added;
                context.SaveChanges();

                return true;
            }

        }