private async void FindUsages()
        {
            try
            {
                xProcessingImage.Visibility = Visibility.Visible;

                ObservableList <BusinessFlow> BizFlows = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <BusinessFlow>();
                await Task.Run(() =>
                {
                    foreach (BusinessFlow BF in BizFlows)
                    {
                        if (mModelItem is ApplicationAPIModel)
                        {
                            foreach (Activity activity in BF.Activities)
                            {
                                foreach (Act act in activity.Acts)
                                {
                                    if (act is ActWebAPIModel && ((ActWebAPIModel)act).APImodelGUID == mModelItem.Guid)
                                    {
                                        ModelItemUsage itemUsage = new ModelItemUsage()
                                        {
                                            HostBusinessFlow = BF, HostBizFlowPath = Path.Combine(BF.ContainingFolder, BF.Name), HostActivityName = activity.ActivityName, HostActivity = activity, Action = act, UsageItem = act, UsageItemName = act.Description, Selected = true /*, UsageExtraDetails = "Number of " + GingerDicser.GetTermResValue(eTermResKey.Activities) + ": " + act.ActivitiesIdentifiers.Count().ToString()*/, Status = ModelItemUsage.eStatus.NotUpdated
                                        };
                                        if (mUsageUpdateType == ApplicationModelBase.eModelUsageUpdateType.SinglePart)
                                        {
                                            if (mModelPart == ApplicationModelBase.eModelParts.ReturnValues)
                                            {
                                                itemUsage.SetItemPartesFromEnum(typeof(ActReturnValue.eItemParts));
                                            }
                                        }
                                        else if (mUsageUpdateType == ApplicationModelBase.eModelUsageUpdateType.MultiParts)
                                        {
                                            itemUsage.SetItemPartesFromEnum(typeof(ApplicationModelBase.eModelParts));
                                        }

                                        ModelItemUsages.Add(itemUsage);
                                    }
                                }
                            }
                        }
                    }
                });
            }
            catch (Exception ex)
            {
                Reporter.ToUser(eUserMsgKey.GetModelItemUsagesFailed, mModelItem.GetNameForFileName(), ex.Message);
            }
            finally
            {
                xProcessingImage.Visibility = Visibility.Collapsed;
            }
        }
 private void SetSamePartToAll(object sender, RoutedEventArgs e)
 {
     if (usageGrid.CurrentItem != null)
     {
         ModelItemUsage a = (ModelItemUsage)usageGrid.CurrentItem;
         foreach (ModelItemUsage usage in ModelItemUsages)
         {
             usage.SelectedItemPart = a.SelectedItemPart;
         }
     }
     else
     {
         Reporter.ToUser(eUserMsgKey.AskToSelectItem);
     }
 }
        private static void UpdateAllReturnValuesInAction(Act act, ApplicationModelBase apiModel, ModelItemUsage usage)
        {
            ActReturnValue.eItemParts ePartToUpdate = (ActReturnValue.eItemParts)Enum.Parse(typeof(ActReturnValue.eItemParts), usage.SelectedItemPart);
            foreach (ActReturnValue apiARV in apiModel.ReturnValues)
            {
                ActReturnValue actARV = act.ActReturnValues.Where(x => x.Guid == apiARV.Guid).FirstOrDefault();
                if (actARV != null) //Exist already in the action - Update it
                {
                    actARV.Active = apiARV.Active;
                    actARV.Status = ActReturnValue.eStatus.Pending;

                    if (ePartToUpdate == ActReturnValue.eItemParts.ExpectedValue || ePartToUpdate == ActReturnValue.eItemParts.All)
                    {
                        actARV.Expected = apiARV.Expected;
                    }
                    if (ePartToUpdate == ActReturnValue.eItemParts.Parameter || ePartToUpdate == ActReturnValue.eItemParts.All)
                    {
                        actARV.ItemName = apiARV.ItemName;
                    }
                    if (ePartToUpdate == ActReturnValue.eItemParts.Path || ePartToUpdate == ActReturnValue.eItemParts.All)
                    {
                        actARV.Path = apiARV.Path;
                    }
                    if (ePartToUpdate == ActReturnValue.eItemParts.SimulatedActual || ePartToUpdate == ActReturnValue.eItemParts.All)
                    {
                        actARV.SimulatedActual = apiARV.SimulatedActual;
                    }
                    if (ePartToUpdate == ActReturnValue.eItemParts.StoreTo || ePartToUpdate == ActReturnValue.eItemParts.All)
                    {
                        if (!string.IsNullOrEmpty(apiARV.StoreToValue))
                        {
                            actARV.StoreTo      = ActReturnValue.eStoreTo.ApplicationModelParameter;
                            actARV.StoreToValue = apiARV.StoreToValue;
                        }
                    }

                    usage.Status = ModelItemUsage.eStatus.Updated;
                }
                else //Not exist in the action - add it
                {
                    if (!string.IsNullOrEmpty(apiARV.StoreToValue))
                    {
                        apiARV.StoreTo = ActReturnValue.eStoreTo.ApplicationModelParameter;
                    }
                    AddNewActReturnValue(act, apiARV);
                }
            }
        }