public async Task UpdateAsync(OriginDto originDto) { var origin = Mapper.Map <OriginDto, Origin>(originDto); await _originRespository.UpdateAsync(origin); var result = await _originRespository.GetSingleAsync(originDto.Id); var mappedResult = Mapper.Map <Origin, OriginDto>(result); await _originElasticsearch.UpdateAsync(mappedResult); }
public async Task <IActionResult> Post([FromBody] OriginDto origin) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var result = await _originService.AddAsync(origin); return(CreatedAtRoute(new { controller = "origins", }, result)); }
public async Task <OriginDto> AddAsync(OriginDto otherDto) { var origin = Mapper.Map <OriginDto, Origin>(otherDto); await _originRespository.AddAsync(origin); var result = await _originRespository.GetSingleAsync(origin.OriginId); var mappedResult = Mapper.Map <Origin, OriginDto>(result); await _originElasticsearch.UpdateAsync(mappedResult); return(mappedResult); }
public async Task <IActionResult> Put([FromRoute] int id, [FromBody] OriginDto origin) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != origin.Id) { return(BadRequest()); } await _originService.UpdateAsync(origin); return(new StatusCodeResult((int)HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> PutOrigin(int id, OriginDto origin) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != origin.Id) { return(BadRequest()); } await _originService.UpdateAsync(origin); return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <bool> CreateAsync(OriginDto model) { var result = false; try { _context.Origins.Add(new Origin { Code = model.Code, Name = model.Name, Description = model.Description, Simbol = model.Simbol }); await _context.SaveChangesAsync(); } catch (Exception e) { // Error logging } return(result); }
public async Task UpdateAsync(OriginDto originDto) { await _client.MapAsync <OriginDto>(d => d.Properties(p => p.String(s => s.Name(n => n.Name).Analyzer("autocomplete")))); var index = await _client.IndexAsync <OriginDto>(originDto); }