public async Task <ActionResult <Item> > CreateItem([FromBody] Item newItem) { try { Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>(); newItem.CreatorId = userInfo.Id; Item created = _is.CreateItem(newItem); created.Creator = userInfo; return(Ok(created)); } catch (System.Exception e) { return(BadRequest(e.Message)); } }
private async void CreateItem(object obj) { var str = obj as String; if (str == null) { throw new ArgumentException(); } //преобразуем строку из параметра в ItemType var item = _itemFactory.CreateItem((ItemType)Enum.Parse(typeof(ItemType), str)); if (_selectedFolder == null) { MessageBox.Show("Не выбрана папка"); } else { await _itemsService.CreateItem(item, _selectedFolder.Id); await GetItemCollection(); } }