private static bool CallSetFavouriteStatus(string id, bool isFavourite)
 {
     SetFavouriteStatusOfStockCompany.Execute(new SetFavouriteStatusOfStockCompanyParameters
     {
         Id          = id,
         IsFavourite = isFavourite
     });
     return(false);
 }
Exemplo n.º 2
0
        private static void executeOperationWithFormValues(IContainerOwner containerOwner, string operationName, NameValueCollection form, HttpFileCollection fileContent)
        {
            var filterFields = new string[] { "ExecuteOperation", "ObjectDomainName", "ObjectName", "ObjectID" };

            switch (operationName)
            {
            case "CreateInformationInput":
            {
                CreateInformationInputParameters parameters = new CreateInformationInputParameters
                {
                    InputDescription = form["InputDescription"],
                    LocationURL      = form["LocationURL"],
                    Owner            = containerOwner
                };
                var createdInformationInput      = CreateInformationInput.Execute(parameters);
                var owningAccount                = containerOwner as TBAccount;
                TBCollaboratingGroup owningGroup = null;
                if (owningAccount == null)
                {
                    TBRGroupRoot groupRoot =
                        TBRGroupRoot.RetrieveFromDefaultLocation(containerOwner.LocationPrefix);
                    owningGroup = groupRoot.Group;
                }
                CreateAndSendEmailValidationForInformationInputConfirmationParameters emailParameters = new CreateAndSendEmailValidationForInformationInputConfirmationParameters
                {
                    OwningAccount    = owningAccount,
                    OwningGroup      = owningGroup,
                    InformationInput = createdInformationInput.InformationInput,
                };
                CreateAndSendEmailValidationForInformationInputConfirmation.Execute(emailParameters);
                break;
            }

            case "CreateSpecifiedInformationObjectWithValues":
            {
                CreateSpecifiedInformationObjectWithValuesParameters parameters = new CreateSpecifiedInformationObjectWithValuesParameters
                {
                    Owner            = containerOwner,
                    ObjectDomainName = form["ObjectDomainName"],
                    ObjectName       = form["ObjectName"],
                    HttpFormData     = filterForm(form, filterFields),
                    HttpFileData     = fileContent,
                };
                CreateSpecifiedInformationObjectWithValues.Execute(parameters);
                break;
            }

            case "DeleteSpecifiedInformationObject":
            {
                DeleteSpecifiedInformationObjectParameters parameters = new DeleteSpecifiedInformationObjectParameters
                {
                    Owner            = containerOwner,
                    ObjectDomainName = form["ObjectDomainName"],
                    ObjectName       = form["ObjectName"],
                    ObjectID         = form["ObjectID"],
                };
                DeleteSpecifiedInformationObject.Execute(parameters);
                break;
            }

            case "SetIsFavouriteStatus":
            {
                bool isFavourite;
                bool.TryParse(form["IsFavourite"], out isFavourite);
                SetFavouriteStatusOfStockCompany.Execute(new SetFavouriteStatusOfStockCompanyParameters
                    {
                        Id          = form["Id"],
                        IsFavourite = isFavourite
                    });
                break;
            }

            case "SetAlarmPrice":
            {
                double alarmPrice;
                double.TryParse(form["AlarmPrice"], out alarmPrice);
                SetAlarmPriceOfStockCompany.Execute(new SetAlarmPriceOfStockCompanyParameters
                    {
                        Id         = form["Id"],
                        AlarmPrice = alarmPrice
                    });
                break;
            }

            case "AddOrUpdatePortfolio":
            {
                AddOrUpdatePortfolio.Execute(new AddOrUpdatePortfolioParameters
                    {
                        Id   = form["Id"],
                        Name = form["Name"]
                    });
                break;
            }

            case "DeletePortfolio":
            {
                RemovePortfolio.Execute(new RemovePortfolioParameters
                    {
                        Id = form["Id"]
                    });
                break;
            }

            case "AddStockCompanyToPortfolio":
            {
                AddStockCompanyToPortfolio.Execute(new AddStockCompanyToPortfolioParameters
                    {
                        PortfolioId    = form["Id"],
                        StockCompanyId = form["StockCompanyId"]
                    });
                break;
            }

            case "RemoveStockCompanyFromPortfolio":
            {
                RemoveStockCompanyFromPortfolio.Execute(new RemoveStockCompanyFromPortfolioParameters
                    {
                        PortfolioId    = form["Id"],
                        StockCompanyId = form["StockCompanyId"]
                    });
                break;
            }

            default:
                throw new NotSupportedException("Operation not (yet) supported: " + operationName);
            }
        }