public void UpdateExample(ExampleDto exampleDto) { using (DictionaryRepository repository = new DictionaryRepository()) { repository.EXAMPLE.UpdateExample(exampleDto); } }
public void Create(ExampleDto exampleDto) { var example = Mapper.Map <Example>(exampleDto); _unitOfWork.Examples.Create(example); _unitOfWork.Save(); }
public void ExampleDto_Constructor() { // Act var result = new ExampleDto(0); // Assert Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(ExampleDto)); }
public async Task <Example> AddExample(ExampleDto dto) { var example = ExampleMapper.ConvertDtoToEntity(dto); await _dbContext.AddAsync(example); await _dbContext.SaveChangesAsync(); return(example); }
public void UpdateExample(ExampleDto exampleDto) { EXAMPLE example = DataSet.FirstOrDefault(m => m.ID == exampleDto.ExampleId); if (example != null) { example.TEXT = exampleDto.ExampleText; Repository.SaveChanges(); } }
public async Task <ActionResult <ExampleDto> > Adicionar(ExampleDto exempleDto) { if (!ModelState.IsValid) { return(CustomResponse(ModelState)); } await _exempleService.Adicionar(_mapper.Map <Example>(exempleDto)); return(CustomResponse(exempleDto)); }
public ActionResult UpdateExample(ExampleDto exampleDto) { if (exampleDto.ExampleId == Guid.Empty) { exampleService.CreateExample(exampleDto); } else { exampleService.UpdateExample(exampleDto); } return(Redirect(Request.UrlReferrer.ToString())); }
public void CreateExample(ExampleDto exampleDto) { EXAMPLE newExample = new EXAMPLE() { ID = Guid.NewGuid(), MEANING_ID = exampleDto.MeaningId, TEXT = exampleDto.ExampleText, }; DataSet.Add(newExample); Repository.SaveChanges(); }
public void Edit(ExampleDto exampleDto) { var updatingExample = _unitOfWork.Examples.Get(exampleDto.Id); if (updatingExample == null) { throw new EntityNotFoundException($"There is no Exampke with id { exampleDto.Id } in the database.", "Example"); } Mapper.Map(exampleDto, updatingExample); _unitOfWork.Examples.Update(updatingExample); _unitOfWork.Save(); }
public async Task <ActionResult> GetById(Guid id) { ExampleDto example = await _mediator.Send(new GetExample { Id = id }); if (example is null) { return(NotFound()); } return(Ok(example)); }
//Example handler method public ExampleDto GetExampleDto(int exampleId) { //Usually the database processing will occur here... ExampleDto response = new ExampleDto() { Id = 1, Name = "Some name", CreatedDate = DateTime.Now.ToLocalTime(), ModifiedDate = DateTime.Now.ToLocalTime(), IsDeleted = false }; return(response); }
public async Task <ActionResult <ExampleDto> > Atualizar(Guid id, ExampleDto exempleDto) { if (id != exempleDto.Id) { NotificarErro("O id informado não é o mesmo que foi passado na consulta"); return(CustomResponse(exempleDto)); } if (!ModelState.IsValid) { return(CustomResponse(ModelState)); } await _exempleService.Atualizar(_mapper.Map <Example>(exempleDto)); return(CustomResponse(exempleDto)); }
public async Task <IActionResult> AddExample(ExampleDto dto) { var example = await _exampleService.AddExample(dto); return(Ok(example)); }
public static Example ConvertDtoToEntity(ExampleDto example) { return(_mapper.Map <Example>(example)); }