public async Task AddItem(Enums.Modules module) { var newItem = new Item(module: module, canEditQuantity: false, showQuantity: true, quantity: 0, included: false); items.Add(newItem); AvailableModules = GetAvailabeModules(); await CalculatePrice(); newItem.IsVisible = true; await Task.CompletedTask; }
// get UserRight of a module that bind to user public UserRight GetUserRightOfModule(string username, Enums.Modules module) { UserRight result = null; var user = GetUsersCollectionByUserName(username); // get group permission if (user != null) { result = new UserRight(); foreach (var group in user.Roles) { var groupModel = GetGroupByGroupName(group.Name); if (groupModel != null) { foreach (var permission in groupModel.ModulePermissions) { if (permission.Name == Enums.GetDisplayName(module)) { result.Read |= permission.UserRight.Read; result.Write |= permission.UserRight.Write; } } } } // combine to user permission foreach (var permission in user.ModulePermissions) { if (permission.Name == Enums.GetDisplayName(module)) { result.Read = permission.UserRight.Read ?? result.Read; result.Write = permission.UserRight.Write ?? result.Write; } } } return(result); }