public async Task UpdateAsync(OtherDto otherDto) { var other = Mapper.Map<OtherDto, Other>(otherDto); await _otherRepository.UpdateAsync(other); var result = await _otherRepository.GetSingleAsync(otherDto.Id); var mappedResult = Mapper.Map<Other, OtherDto>(result); await _otherElasticsearch.UpdateAsync(mappedResult); }
//Not async public OtherDto Add(OtherDto otherDto) { var other = Mapper.Map<OtherDto, Other>(otherDto); _otherRepository.Add(other); var result = _otherRepository.GetSingle(other.OtherId); var mappedResult = Mapper.Map<Other, OtherDto>(result); _otherElasticsearch.Update(mappedResult); return mappedResult; }
public async Task<IHttpActionResult> PutOther(int id, OtherDto otherDto) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != otherDto.Id) { return BadRequest(); } await _otherService.UpdateAsync(otherDto); return StatusCode(HttpStatusCode.NoContent); }
public void Update(OtherDto otherDto) { // Adds an analayzer to the name property in FermentableDto object. _client.Map<OtherDto>(d => d.Properties(p => p.String(s => s.Name(n => n.Name).Analyzer("autocomplete")))); _client.Index<OtherDto>(otherDto); }
public async Task<IIndexResponse> UpdateAsync(OtherDto otherDto) { // Adds an analayzer to the name property in FermentableDto object. await _client.MapAsync<OtherDto>(d => d.Properties(p => p.String(s => s.Name(n => n.Name).Analyzer("autocomplete")))); return await _client.IndexAsync<OtherDto>(otherDto); }
public async Task<IHttpActionResult> PostOther(OtherDto otherDto) { if (!ModelState.IsValid) { return BadRequest(ModelState); } var result = await _otherService.AddAsync(otherDto); return CreatedAtRoute("DefaultApi", new { controller = "others", }, result); }