This commit is contained in:
2023-08-10 21:57:55 +03:00
parent 25184e9edc
commit a09fc7ece3
19 changed files with 230 additions and 68 deletions
+32
View File
@@ -130,6 +130,17 @@ public class ItemService
return _mapper.Map<List<ItemDto>>(_itemRepository.GetByCategory(userId, categoryId));
}
public List<ItemDto> GetByUncategorized(Guid userId)
{
var itemGlobals = _itemGlobalRepository.GetAvailableToUser(userId);
foreach (var itemGlobal in itemGlobals)
{
GetOrCreate(userId, itemGlobal);
}
return GetByCategory(userId, userId);
}
public Exec<ItemDto, GeneralExecStatus> Update(Guid userId, Guid motionId, Guid categoryId)
{
var result = new Exec<ItemDto, GeneralExecStatus>(GeneralExecStatus.success);
@@ -204,4 +215,25 @@ public class ItemService
return _mapper.Map<List<ItemDto>>(_itemRepository.Find(userId, term, limit));
}
public GeneralExecStatus UpdateItemsCategory(Guid userId, Guid categoryId, List<Guid> items)
{
var category = _itemCategoryRepository.Get(userId, categoryId);
if (category == null)
{
return GeneralExecStatus.not_found;
}
foreach (var item in items)
{
var dbItem = _itemRepository.GetByGlobal(userId, item);
if (dbItem != null)
{
dbItem.CategoryId = category.Id;
_itemRepository.Update(dbItem);
}
}
return GeneralExecStatus.success;
}
}