Exemplo n.º 1
0
        public void Update(UpdateGameSetting entity)
        {
            using (var transaction = _entityContext.Database.BeginTransaction())
            {
                try
                {
                    GameSettings gameSetting =
                        _entityContext.GameSettings.FirstOrDefault(x => x.GameSettingId == entity.GameSettingId);

                    if (gameSetting == null)
                    {
                        throw new NullReferenceException();
                    }

                    gameSetting.GameLength = entity.GameLength;
                    gameSetting.UpdatedAt  = DateTime.UtcNow;

                    _entityContext.Update(gameSetting);
                    _entityContext.SaveChanges();
                    transaction.Commit();
                }
                catch (Exception)
                {
                    transaction.Rollback();
                    throw;
                }
            }
        }
Exemplo n.º 2
0
 public void Update(UpdateGameSetting entity)
 {
     try
     {
         _gameSettingsRepository.Update(entity);
     }
     catch (MySqlException)
     {
         throw new ConnectionException();
     }
     catch (Exception)
     {
         throw new OperationException("An error occured while updating Game Settings!");
     }
 }
Exemplo n.º 3
0
        public IActionResult Edit(UpdateGameSetting entity)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    _gameSettingsLogic.Update(entity);

                    return(RedirectToAction("Index"));
                }
                catch (Exception exception)
                {
                    View(exception.Message);
                }
            }

            return(View());
        }
Exemplo n.º 4
0
        public IActionResult Edit(int id)
        {
            try
            {
                GameSettings gameSettings = _gameSettingsLogic.GetSettingsById(id);

                UpdateGameSetting updateGameSetting = new UpdateGameSetting
                {
                    GameSettingId = gameSettings.GameSettingId,
                    GameLength    = gameSettings.GameLength,
                    UpdatedAt     = gameSettings.UpdatedAt
                };

                return(View("Edit", updateGameSetting));
            }
            catch (Exception ex)
            {
                _logger.Log(LogLevel.Error, $"The following error occurred: {ex.Message} @ {GetType().Name}");
                ViewBag.ErrorMessage = ex.Message;

                return(View("Index"));
            }
        }