Esempio n. 1
0
        public Log Save(Log log)
        {
            var state = log.Id == 0 ? EntityState.Added : EntityState.Modified;

            context.Entry(log).State = state;
            context.SaveChanges();
            return(log);
        }
Esempio n. 2
0
        public bool DeleteUserById(int id)
        {
            User user = context.Users.Find(id);

            if (user == null)
            {
                return(false);
            }
            var state = EntityState.Deleted;

            context.Entry(user).State = state;
            context.SaveChanges();
            return(true);
        }
Esempio n. 3
0
        // cadastra erro com base em objeto com dadso complatos
        public void RegisterError(CompleteDataErrorViewModel errorData)
        {
            DefinirValoresPadrao(errorData);

            var error = new Error()
            {
                Code          = errorData.ErrorCode,
                Description   = errorData.ErrorDescription,
                EnvironmentId = errorData.EnvironmentId,
                LevelId       = errorData.LevelId,
                Title         = errorData.ErrorTitle,
                SituationId   = errorData.SituationId,
            };

            var errorSaved = _context.Errors.Add(error);


            _context.ErrorOccurrences.Add(new ErrorOccurrence
            {
                Error = error,
                //ErrorId = errorSaved.Entity.Id,
                DateTime   = DateTime.Parse(errorData.DateTime),
                Details    = errorData.ErrorDetails,
                EventCount = errorData.ErrorEventCount,
                Origin     = errorData.ErrorOrigin,
                UserId     = errorData.UserId,
            });


            _context.SaveChanges();
        }
Esempio n. 4
0
        public User Save(User user)
        {
            var state = user.Id == 0 ? EntityState.Added : EntityState.Modified;

            _context.Entry(user).State = state;
            _context.SaveChanges();
            return(user);
        }
        public Environment RegisterEnvironment(Environment environment)
        {
            //_context.Environments.Add(new Models.Environment { EnvironmentName = name });

            //if (_context.Environments.FirstOrDefault(e => e.EnvironmentName == name) != null)
            //{
            //    return true;
            //}

            //return false;

            var state = environment.Id == 0 ? EntityState.Added : EntityState.Modified;

            _context.Entry(environment).State = state;
            _context.SaveChanges();
            return(environment);
        }