public async Task <IActionResult> PutError(int id, Error error)
        {
            if (id != error.Id)
            {
                return(BadRequest());
            }

            _context.Entry(error).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ErrorExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #2
0
        public Log Save(Log log)
        {
            var state = log.Id == 0 ? EntityState.Added : EntityState.Modified;

            context.Entry(log).State = state;
            context.SaveChanges();
            return(log);
        }
예제 #3
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);
        }
예제 #4
0
        public async Task <IActionResult> PutLevel(int id, Level level)
        {
            if (id != level.LevelId)
            {
                return(BadRequest());
            }

            _context.Entry(level).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LevelExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutUser(int id, User user)
        {
            if (id != user.Id)
            {
                return(BadRequest());
            }

            //max: colcoa a senha que vem em md5
            user.Password = user.Password.ToHashMD5();

            _context.Entry(user).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #6
0
        public async Task <IActionResult> PutSituation(int id, Situation situation)
        {
            if (id != situation.SituationId)
            {
                return(BadRequest());
            }

            _context.Entry(situation).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SituationExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #7
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);
        }