public async Task <ActionResult <ItemLocation> > PostItemLocation([FromBody] ItemLocationDto itemLocation) { var map = mapper.Map <ItemLocation>(itemLocation); var post = await _itemLocationRepository.PostItemLocation(map); return(Ok(post)); }
public async Task <IActionResult> PutItemLocation(int id, [FromBody] ItemLocationDto itemLocation) { if (itemLocation == null) { return(BadRequest()); } try { var item = await _itemLocationRepository.PutItemLocation(id, itemLocation); if (item == null) { return(BadRequest()); } else { return(Ok(item)); } } catch (DbUpdateConcurrencyException) { if (!ItemLocationExists(id)) { return(NotFound()); } else { throw; } } }
public async Task <ItemLocation> PutItemLocation(int id, ItemLocationDto itemLocation) { var item = await context.ItemLocations.Where(i => i.Id == id).SingleOrDefaultAsync(); if (item == null) { return(null); } else { var map = mapper.Map(itemLocation, item); context.ItemLocations.Update(map); await context.SaveChangesAsync(); return(map); } }