Example #1
0
        public virtual T Excluir(T model)
        {
            using (ContainerControlContext dao = new ContainerControlContext())
            {
                dao.Entry(model).State = EntityState.Deleted;

                dao.SaveChanges();
            }
            return(model);
        }
        public override Container Excluir(Container ctnr)
        {
            using (ContainerControlContext dao = new ContainerControlContext())
            {
                dao.Entry(ctnr).State = EntityState.Deleted;
                //dao.Entry(ctnr.CodigoIso).State = EntityState.Unchanged;

                dao.SaveChanges();
            }
            return(ctnr);
        }
Example #3
0
        public virtual T Atualizar(T model)
        {
            T entity = null;

            using (ContainerControlContext dao = new ContainerControlContext())
            {
                entity = dao.Set <T>().Attach(model);
                dao.Entry(entity).State = EntityState.Modified;
                dao.SaveChanges();
            }
            return(entity);
        }
Example #4
0
        public virtual T Inserir(T model)
        {
            T entity = null;

            using (ContainerControlContext dao = new ContainerControlContext())
            {
                entity = dao.Set <T>().Add(model);
                dao.Entry(entity).State = EntityState.Added;
                dao.SaveChanges();
            }
            return(entity);
        }
        public override Container Inserir(Container model)
        {
            Container entity = null;

            using (ContainerControlContext dao = new ContainerControlContext())
            {
                entity = dao.Containers.Add(model);

                dao.Entry(entity).State = EntityState.Added;
                if (model.CodigoIso != null)
                {
                    dao.Entry(model.CodigoIso).State = EntityState.Unchanged;
                }

                dao.SaveChanges();
            }
            return(entity);
        }
        public override Container Atualizar(Container model)
        {
            Container entity = null;

            using (ContainerControlContext dao = new ContainerControlContext())
            {
                entity = dao.Containers.FirstOrDefault(c => c.Id == model.Id);
                entity.Populate(model);

                dao.Entry(entity).State = EntityState.Modified;
                if (model.CodigoIso != null)
                {
                    dao.Entry(model.CodigoIso).State = EntityState.Unchanged;
                }

                dao.SaveChanges();
            }
            return(entity);
        }