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());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace MyOffice.Web.Models.Item;
|
||||
|
||||
public class ItemChangeCategoryModel
|
||||
{
|
||||
public string category { get; set; } = null!;
|
||||
public List<string> Items { get; set; } = null!;
|
||||
}
|
||||
@@ -1,8 +1,7 @@
|
||||
namespace MyOffice.Web.Models.Item
|
||||
namespace MyOffice.Web.Models.Item;
|
||||
|
||||
public class ItemEditModel
|
||||
{
|
||||
public class ItemEditModel
|
||||
{
|
||||
public string Id { get; set; } = null!;
|
||||
public string Category { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
public string Id { get; set; } = null!;
|
||||
public string Category { get; set; } = null!;
|
||||
}
|
||||
Reference in New Issue
Block a user