コード例 #1
0
        public void DeleteCharacter()
        {
            _characterRepository.Delete(Arg.Any <int>());
            _unitOfWork.Commit().Returns(true);

            var result = _service.Delete(1);

            Assert.True(result);
            _characterRepository.Received().Delete(Arg.Any <int>());
            _unitOfWork.Received().Commit();
        }
コード例 #2
0
 public Option <SuccessResult, ErrorResult> Delete(DeleteByIdCommand command)
 {
     return(_deleteByIdCommandValidator
            .Validate(command)
            .OnSuccess(errorBuilder =>
     {
         var option = _characterRepository.GetById(command);
         option.MatchSome(x => _characterRepository.Delete(x));
         option.MatchNone(errorBuilder.AddRecordNotFound);
     }));
 }
コード例 #3
0
 public async Task Delete(int id)
 {
     try
     {
         await _CharacterRepository.Delete(id);
     }
     catch (Exception ex)
     {
         File.WriteAllText("log.txt", ex.Message + " - " + ex.StackTrace);
         throw new Exception("Erro no banco de dados, contate o administrador");
     }
 }
コード例 #4
0
        private void DeleteCharacter()
        {
            int id = io.PromptUserForInt("Enter Id to remove");

            repo.Delete(id);
            Character deletedInfo = repo.ReadById(io.PromptUserForInt("Enter Id for character"));

            if (deletedInfo == null)
            {
                Console.WriteLine("No character found");
            }
        }
コード例 #5
0
        public async Task <IResponse> Handle(DeleteCharacterCommand command)
        {
            command.Validate();

            if (command.Invalid)
            {
                return(new GenericCommandResponse(false, "Comando Inválido", command.Notifications));
            }

            await _characterRepository.Delete(command.Id);

            return(new GenericCommandResponse(true, "OK", command));
        }
コード例 #6
0
 public IActionResult Delete(int id)
 {
     if (!_loginManager.IsLoggedIn(HttpContext?.Session) || !_repo.Read().Any(c =>
                                                                              c.OwningPlayerid == HttpContext.Session.GetInt32(ContextData.PlayerId.ToString()) &&
                                                                              c.Id == id)) //ensure they do own the character.
     {
         return(RedirectToAction("Login", "Player"));
     }
     _repo.Delete(new Character()
     {
         Id = id
     });
     return(RedirectToAction("Index"));
 }
コード例 #7
0
        /// <summary>
        /// delete a character from the data file
        /// </summary>
        /// <param name="character">character</param>
        /// <param name="dalErrorCode">status code</param>
        /// <param name="message">message</param>
        public void DeleteCharacter(int id, out DalErrorCode dalErrorCode, out string message)
        {
            message = "";

            using (_characterRepository)
            {
                if (CharacterDocumentExists(id, out dalErrorCode))
                {
                    _characterRepository.Delete(id, out dalErrorCode);

                    if (dalErrorCode == DalErrorCode.ERROR)
                    {
                        message = "There was an error connecting to the data file.";
                    }
                }
                else
                {
                    message      = $"Character with id {id} does not exist.";
                    dalErrorCode = DalErrorCode.ERROR;
                }
            }
        }
コード例 #8
0
        public async Task DeleteAsync(int id)
        {
            Character?characterToDelete = await _characterRepository.FindAsync(id);

            _characterRepository.Delete(characterToDelete);
        }
コード例 #9
0
        public bool Delete(int id)
        {
            _repository.Delete(id);

            return(_unitOfWork.Commit());
        }
コード例 #10
0
ファイル: CharactersService.cs プロジェクト: kubabuda/sw_api
 public void DeleteCharacter(string name)
 {
     _repository.Delete(name);
 }
コード例 #11
0
 public void Delete(int id)
 {
     _globalService.Delete(id);
 }
コード例 #12
0
ファイル: CharactersController.cs プロジェクト: kazeed/swapi
        public IActionResult Delete(Guid id)
        {
            repository.Delete(id);

            return(new NoContentResult());
        }
コード例 #13
0
 public void DeleteCharacter(int id)
 {
     _characterRepository.Delete(id);
 }
コード例 #14
0
 public void Delete(int id)
 {
     _service.Delete(id);
 }