public IActionResult UpdateUnit(int id, [FromBody] UnitResource unitResource) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var unit = unitRepository.Get(id); mapper.Map(unitResource, unit); uow.Complete(); var result = mapper.Map <Unit, UnitResource>(unit); return(Ok(result)); }
public IActionResult CreateUnit([FromBody] UnitResource unitResource) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var unit = mapper.Map <UnitResource, Unit>(unitResource); unitRepository.Add(unit); uow.Complete(); var result = mapper.Map <Unit, UnitResource>(unit); return(Ok(result)); }
private UnitVM CreateItem(UnitResource unit) => new UnitVM() { Model = unit, PreviewProvider = PreviewProvider, AbilityListProvider = AbilityListProvider };