Пример #1
0
 public async Task UpdateRowAsync(ItemCategoryLookupView updateVeiwEntity)
 {
     if (await IsDuplicate(updateVeiwEntity))
     {
         _gridSettings.PopUpRef.ShowNotification(PopUpAndLogNotification.NotificationType.Error, $"Category Name: {updateVeiwEntity.CategoryName} - already exists, cannot be updated", "Exists already");
     }
     else
     {
         if (IsValid(updateVeiwEntity))
         {
             ItemCategoryLookup updatedItemCategoryLookup = GetItemFromView(updateVeiwEntity);
             // update and check for errors
             if (await UpdateItemAsync(updateVeiwEntity) != AppUnitOfWork.CONST_WASERROR)
             {
                 if ((updateVeiwEntity.HasWooCategoryMap) && (await UpdateWooCategoryMap(updateVeiwEntity) == AppUnitOfWork.CONST_WASERROR))
                 {
                     _gridSettings.PopUpRef.ShowNotification(PopUpAndLogNotification.NotificationType.Error, $"WooCategory map for Item: {updateVeiwEntity.CategoryName} - {_appUnitOfWork.GetErrorMessage()}", "Error updating");
                 }
                 //else
                 //    PopUpRef.ShowNotification(PopUpAndLogNotification.NotificationType.Success, $"Category: {updatedItem.CategoryName} was updated.");
             }
         }
         else
         {
             string pMessage = $"Category Item {updateVeiwEntity.CategoryName} cannot be parent and child.";
             _gridSettings.PopUpRef.ShowNotification(PopUpAndLogNotification.NotificationType.Error, pMessage, "Error updating");
         }
     }
     await LoadAllViewItems();   // reload the list so the latest item is displayed
 }
Пример #2
0
        async Task <int> UpdateWooCategoryMap(ItemCategoryLookupView updatedViewEntity)
        {
            int _recsUpdated = 0;

            WooCategoryMap updateWooCategoryMap = await GetWooMappedItemAsync(updatedViewEntity.ItemCategoryLookupId);

            if (updateWooCategoryMap != null)
            {
                if (updateWooCategoryMap.CanUpdate == updatedViewEntity.CanUpdateWooMap)
                {
                    // not necessary to display message.
                    //    PopUpRef.ShowNotification(PopUpAndLogNotification.NotificationType.Warning, $"Woo Category Map for category: {pUpdatedItem.CategoryName} has not changed, so was not updated?");
                }
                else
                {
                    updateWooCategoryMap.CanUpdate = (bool)updatedViewEntity.CanUpdateWooMap;
                    IAppRepository <WooCategoryMap> wooCategoryMapRepository = _appUnitOfWork.Repository <WooCategoryMap>();
                    _recsUpdated = await wooCategoryMapRepository.UpdateAsync(updateWooCategoryMap);

                    _gridSettings.PopUpRef.ShowNotification(PopUpAndLogNotification.NotificationType.Success, $"Category: {updatedViewEntity.CategoryName} was updated.");
                }
            }
            else
            {
                _gridSettings.PopUpRef.ShowNotification(PopUpAndLogNotification.NotificationType.Error, $"Woo Category Map for category: {updatedViewEntity.CategoryName} is no longer found, was it deleted?");
            }

            return(_recsUpdated);
        }
Пример #3
0
 public async Task <int> DoGroupActionAsync(ItemCategoryLookupView toVeiwEntity, BulkAction selectedAction)
 {
     if (selectedAction == BulkAction.AllowWooSync)
     {
         toVeiwEntity.CanUpdateWooMap = true;
     }
     else if (selectedAction == BulkAction.DisallowWooSync)
     {
         toVeiwEntity.CanUpdateWooMap = false;
     }
     return(await UpdateWooCategoryMap(toVeiwEntity));
 }
Пример #4
0
        public ItemCategoryLookup GetItemFromView(ItemCategoryLookupView fromVeiwEntity)
        {
            ItemCategoryLookup _newItemCategoryLookup = new ItemCategoryLookup
            {
                ItemCategoryLookupId = fromVeiwEntity.ItemCategoryLookupId,
                CategoryName         = fromVeiwEntity.CategoryName,
                UsedForPrediction    = fromVeiwEntity.UsedForPrediction,
                ParentCategoryId     = (fromVeiwEntity.ParentCategoryId == Guid.Empty) ? null : fromVeiwEntity.ParentCategoryId,
                Notes = fromVeiwEntity.Notes,
            };

            return(_newItemCategoryLookup);
        }
Пример #5
0
        public void NewItemDefaultSetter(ItemCategoryLookupView newViewEntity)
        {
            if (newViewEntity == null)
            {
                newViewEntity = new ItemCategoryLookupView();
            }

            newViewEntity.CategoryName      = "Cat name (must be unique)";
            newViewEntity.Notes             = $"Added {DateTime.Now.Date}";
            newViewEntity.ParentCategoryId  = Guid.Empty;
            newViewEntity.UsedForPrediction = true;

            //return _newVeiwEntity;
        }
Пример #6
0
        public async Task DeleteEntityAsync(ItemCategoryLookupView deleteVeiwEntity)
        {
            IAppRepository <ItemCategoryLookup> _ItemCategoryLookupRepository = _appUnitOfWork.Repository <ItemCategoryLookup>();

            var _recsDelete = await _ItemCategoryLookupRepository.DeleteByIdAsync(deleteVeiwEntity.ItemCategoryLookupId);     //DeleteByAsync(icl => icl.ItemCategoryLookupId == SelectedItemCategoryLookup.ItemCategoryLookupId);

            if (_recsDelete == AppUnitOfWork.CONST_WASERROR)
            {
                _gridSettings.PopUpRef.ShowNotification(PopUpAndLogNotification.NotificationType.Error, $"Category: {deleteVeiwEntity.CategoryName} is no longer found, was it deleted?");
            }
            else
            {
                _gridSettings.PopUpRef.ShowNotification(PopUpAndLogNotification.NotificationType.Success, $"Category: {deleteVeiwEntity.CategoryName} was it deleted?");
            }
        }
Пример #7
0
        public async Task InsertRowAsync(ItemCategoryLookupView newVeiwEntity)
        {
            IAppRepository <ItemCategoryLookup> _ItemCategoryLookupRepository = _appUnitOfWork.Repository <ItemCategoryLookup>();

            // first check we do not already have a category like this.
            if (await _ItemCategoryLookupRepository.FindFirstAsync(icl => icl.CategoryName == newVeiwEntity.CategoryName) == null)
            {
                int _recsAdded = await _ItemCategoryLookupRepository.AddAsync(GetItemFromView(newVeiwEntity));

                if (_recsAdded != AppUnitOfWork.CONST_WASERROR)
                {
                    _gridSettings.PopUpRef.ShowNotification(PopUpAndLogNotification.NotificationType.Success, $"{newVeiwEntity.CategoryName} - {_appUnitOfWork.GetErrorMessage()}", "Category Added");
                }
                else
                {
                    _gridSettings.PopUpRef.ShowNotification(PopUpAndLogNotification.NotificationType.Error, $"{newVeiwEntity.CategoryName} - {_appUnitOfWork.GetErrorMessage()}", "Error adding Category");
                }
            }
            else
            {
                _gridSettings.PopUpRef.ShowNotification(PopUpAndLogNotification.NotificationType.Error, $"{newVeiwEntity.CategoryName} already exists, so could not be added.");
            }
            await LoadAllViewItems();   // reload the list so the latest item is displayed
        }
Пример #8
0
 public Task AddWooItemAsync(ItemCategoryLookupView selectedItemCategoryLookup)
 {
     throw new NotImplementedException();
 }