fix
This commit is contained in:
@@ -101,11 +101,13 @@ public class SettingsItemController : BaseApiController
|
||||
}
|
||||
|
||||
[HttpGet("~/api/settings/items")]
|
||||
public ObjectResult Items([AsGuid] string? category)
|
||||
public ObjectResult Items([AsGuid] string category)
|
||||
{
|
||||
var list = category.IsMissing()
|
||||
? _itemService.GetAll(UserId)
|
||||
: _itemService.GetByCategory(UserId, category!.AsGuid());
|
||||
var categoryId = category.AsGuid();
|
||||
|
||||
var list = categoryId != UserId
|
||||
? _itemService.GetByCategory(UserId, categoryId)
|
||||
: _itemService.GetByUncategorized(UserId);
|
||||
|
||||
return Ok(_mapper.Map<List<ItemViewModel>>(list.OrderBy(x => x.Name)));
|
||||
}
|
||||
@@ -128,4 +130,23 @@ public class SettingsItemController : BaseApiController
|
||||
throw new NotSupportedException(exec.Status.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost("~/api/settings/items")]
|
||||
public ObjectResult Items(ItemChangeCategoryModel request)
|
||||
{
|
||||
var exec = _itemService.UpdateItemsCategory(UserId, request.category.AsGuid(), request.Items.Select(x => x.AsGuid()).ToList());
|
||||
|
||||
switch (exec)
|
||||
{
|
||||
case GeneralExecStatus.not_found:
|
||||
return ProblemBadResponse("Category not found.");
|
||||
case GeneralExecStatus.failure:
|
||||
return ProblemBadResponse("Update failed.");
|
||||
case GeneralExecStatus.success:
|
||||
return Ok(new {});
|
||||
|
||||
default:
|
||||
throw new NotSupportedException(exec.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user