public async Task <IActionResult> ActivateItem(int id) { if (id == 0) { ModelState.AddModelError("Item Error", "Can not activate item with id 0."); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var item = await _repo.GetItem(id); bool result = await _repo.ActivateItem(item); if (result) { User currentUser = _userManager.FindByNameAsync(User.Identity.Name).Result; result = await _eventLogRepo.AddEventLog(EventType.Activated, "genstand", item.Template.Name, item.Id, currentUser); } return(result ? StatusCode(200) : BadRequest()); }