public async Task UpdateAsync(PayingItem item) { try { (var oldPayingItem, var newPayingItem) = await GetNewAndOldItems(item); _repository.Update(item); await _repository.SaveAsync(); await _serviceTrigger.Update(oldPayingItem, newPayingItem); } catch (DomainModelsException e) { throw new ServiceException($"Ошибка в сервисе {nameof(PayingItemService)} в методе {nameof(UpdateAsync)} при обращении к БД", e); } }
public async Task UpdateAsync(PayingItem item) { var typeOfFlowId = (await _categoryService.GetItemAsync(item.CategoryID)).TypeOfFlowID; var categories = (await _typeOfFlowService.GetCategoriesAsync(typeOfFlowId)).Where(x => x.UserId == item.UserId); var oldCategoryId = await GetCategoryIdAsync(categories, item.ItemID); var oldCategory = await _categoryService.GetItemAsync(oldCategoryId); var oldPayingItem = oldCategory.PayingItem.FirstOrDefault(x => x.ItemID == item.ItemID); var newItem = new PayingItem() { Category = oldCategory, AccountID = item.AccountID, Summ = item.Summ }; await _payingItemService.UpdateAsync(item); await _serviceTrigger.Update(oldPayingItem, newItem); }