public IActionResult Create([FromBody] PersonViewModel person) { var model = person.Adapt <Person>(); model.OwnerId = _activeUser.GetUserId(); _peopleRepository.Add(model); return(Created(nameof(GetById), new { id = model.Id })); }
public IActionResult Update(int id, [FromBody] PersonViewModel person) { var model = _peopleRepository.Get(id); if (model == null) { return(NotFound()); } else if (model.OwnerId != _activeUser.GetUserId()) { return(Forbid()); } person.Adapt(model); _peopleRepository.Edit(model); return(Ok()); }