//public ExpenseHeadDetailsArgs CreateArgs()
        //{
        //    return new ExpenseHeadDetailsArgs
        //    {
        //        ExpenseHeadId = Item?.ExpenseHeadId ?? 0
        //    };
        //}


        protected override async Task <bool> SaveItemAsync(RoleModel model)
        {
            try
            {
                if (IsProcessing)
                {
                    return(false);
                }
                IsProcessing = true;
                StartStatusMessage("Saving Role...");
                RoleViewModel.ShowProgressRing();
                if (model.RoleId <= 0)
                {
                    await RoleService.AddRoleAsync(model);
                }
                else
                {
                    await RoleService.UpdateRoleAsync(model);
                }
                ClearItem();
                await RoleListViewModel.RefreshAsync();

                IsProcessing = false;
                ShowPopup("success", "Role is Saved");
                EndStatusMessage("Role saved");
                LogInformation("Role", "Save", "Role saved successfully", $"Role {model.RoleId} '{model.Name}' was saved successfully.");
                return(true);
            }
            catch (Exception ex)
            {
                IsProcessing = false;
                ShowPopup("error", "Role is not Saved");
                StatusError($"Error saving Role: {ex.Message}");
                LogException("Role", "Save", ex);
                return(false);
            }
            finally {
                RoleViewModel.HideProgressRing();
            }
        }
        private async void OnListMessage(RoleListViewModel sender, string message, object args)
        {
            var current = Item;

            if (current != null)
            {
                switch (message)
                {
                case "ItemsDeleted":
                    if (args is IList <RoleModel> deletedModels)
                    {
                        if (deletedModels.Any(r => r.RoleId == current.RoleId))
                        {
                            await OnItemDeletedExternally();
                        }
                    }
                    break;

                case "ItemRangesDeleted":
                    try
                    {
                        var model = await RoleService.GetRoleAsync(current.RoleId);

                        if (model == null)
                        {
                            await OnItemDeletedExternally();
                        }
                    }
                    catch (Exception ex)
                    {
                        LogException("Role", "Handle Ranges Deleted", ex);
                    }
                    break;
                }
            }
        }
 public RoleDetailsViewModel(IDropDownService dropDownService, IRoleService roleService, IFilePickerService filePickerService, ICommonServices commonServices, RoleListViewModel villageListViewModel, RoleViewModel roleViewModel) : base(commonServices)
 {
     DropDownService   = dropDownService;
     FilePickerService = filePickerService;
     RoleService       = roleService;
     RoleListViewModel = villageListViewModel;
     RoleViewModel     = roleViewModel;
 }