Пример #1
0
        public Users Save(Users user)
        {
            var state = user.UserId == 0 ? EntityState.Added : EntityState.Modified;

            _context.Entry(user).State = state;
            _context.Add(user);
            _context.SaveChanges();
            return(user);
        }
        public Infra.Entidades.Environment Save(Infra.Entidades.Environment item)
        {
            var state = item.EnvironmentId == 0 ? EntityState.Added : EntityState.Modified;

            _context.Entry(item).State = state;
            _context.Add(item);
            _context.SaveChanges();
            return(item);
        }
Пример #3
0
        public Level Save(Level item)
        {
            var state = item.LevelId == 0 ? EntityState.Added : EntityState.Modified;

            _context.Entry(item).State = state;
            _context.Add(item);
            _context.SaveChanges();
            return(item);
        }
Пример #4
0
        public Error Save(Error item)
        {
            var state = item.ErrorId == 0 ? EntityState.Added : EntityState.Modified;

            _context.Entry(item).State = state;
            _context.Add(item);
            _context.SaveChanges();
            return(item);
        }
Пример #5
0
        public HttpResponseMessage Incluir(SolLog model)
        {
            var context = new CentralContext();

            try
            {
                model.cdUsuario        = 74;
                model.cdDocumentoTipo  = 0;
                model.txChave          = "SistemaInventario";
                model.dtLog            = DateTime.Now;
                model.nmUsuario        = "Thiago Aguiar";
                model.VersaoAplicativo = 16;
                model.Estacao          = "SRVALVORADA";
                model.dtInicio         = DateTime.Now;

                context.SolLogs.Add(model);
                context.SaveChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
Пример #6
0
        public Logs ArchiveLog(int logId)
        {
            var logToArchive = _context.Logs.Find(logId);

            if (logToArchive == null)
            {
                return(null);
            }

            logToArchive.Archived = true;

            _context.Entry(logToArchive).State = EntityState.Modified;
            _context.SaveChanges();

            return(logToArchive);
        }
Пример #7
0
        public Alert Add(Alert alert)
        {
            Alert ret = context.Add <Alert>(alert).Entity;

            context.SaveChanges();

            return(ret);
        }
Пример #8
0
        public User Add(User user)
        {
            User ret = context.Add <User>(user).Entity;

            context.SaveChanges();

            return(ret);
        }
        public HttpResponseMessage Editar(SolParametro model)
        {
            var context = new CentralContext();

            try
            {
                context.Entry(model).State = EntityState.Modified;
                context.SaveChanges();
            }

            catch (Exception ex)
            {
                throw ex;
            }

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
Пример #10
0
        public HttpResponseMessage Editar(EstoqueContabil model)
        {
            var context = new CentralContext();

            try
            {
                context.Entry(model).State = EntityState.Modified;
                context.SaveChanges();
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse <dynamic>(HttpStatusCode.InternalServerError, new
                {
                    Error = ex.Message
                }));
            }

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
Пример #11
0
 public void Add(TEntity obj)
 {
     Db.Set <TEntity>().Add(obj);
     Db.SaveChanges();
 }
Пример #12
0
 public void Commit()
 {
     Db.SaveChanges();
 }