Я пытаюсь опубликовать действительно простую модель.
Код: Выделить всё
public string MomentCategoryName { get; set; }
Код: Выделить всё
public async Task PostAsync(MomentCategoryModel momentCategory)
{
using (HttpResponseMessage response = await _api.ApiClient.PostAsJsonAsync("api/MomentCategory/Create", momentCategory))
{
if (!response.IsSuccessStatusCode)
{
throw new Exception();
}
}
}
PostMomentCategory в MomentCategoryController получает MomentCategoryModel из другой библиотеки:
Код: Выделить всё
[BsonId]
[BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]
public string Id { get; set; }
public string MomentCategoryName { get; set; }
Код: Выделить всё
[HttpPost]
[Route("Create")]
public void PostMomentCategory(MomentCategoryModel model)
{
_momentCategoryData.CreateMomentCategory(model);
}
Код: Выделить всё
public async Task GetAllAsync()
{
using (HttpResponseMessage response = await _api.ApiClient.GetAsync("api/MomentCategory/GetAll"))
{
if (response.IsSuccessStatusCode)
{
var result = await response.Content.ReadFromJsonAsync();
return result;
}
else
{
throw new Exception();
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/714 ... nc-c-sharp
Мобильная версия