public IHttpActionResult CreateNewModel(RebalanceCreationModel model)
 {
     if (model != null && ModelState.IsValid)
     {
         //rebRepo.CreateNewModel(model, User.Identity.GetUserId());
         return Ok(new { modelId= "modelIdValue"});
     }
     return BadRequest();
 }
Esempio n. 2
0
        public IHttpActionResult CreateNewModel_Client(RebalanceCreationModel model)
        {
            Client      client      = edisRepo.GetClientSync(User.Identity.GetUserId(), DateTime.Now);
            ClientGroup clientGroup = edisRepo.GetClientGroupSync(client.ClientGroupId, DateTime.Now);

            if (model != null)
            {
                List <Domain.Portfolio.Rebalance.TemplateDetailsItemParameter> parameters = new List <Domain.Portfolio.Rebalance.TemplateDetailsItemParameter>();
                foreach (var parameter in model.parameters)
                {
                    parameters.Add(new Domain.Portfolio.Rebalance.TemplateDetailsItemParameter {
                        EquityId         = parameter.parameterId,
                        ItemName         = parameter.parameterName,
                        CurrentWeighting = (double)parameter.weighting,
                        ModelId          = model.modelId,
                        identityMetaKey  = parameter.identityMetaKey
                    });
                }
                ;

                Domain.Portfolio.Rebalance.RebalanceModel newModel = new Domain.Portfolio.Rebalance.RebalanceModel {
                    ModelId       = model.modelId,
                    ClientId      = User.Identity.GetUserId(),
                    ClientGroupId = clientGroup.Id,
                    ModelName     = model.name,
                    ProfileId     = (int)Enum.Parse(typeof(RebalanceModelProfile), model.profileId),
                    TemplateDetailsItemParameters = parameters
                };

                if (model.modelId != null)
                {
                    edisRepo.UpdateRebalanceModel(newModel);
                }
                else
                {
                    edisRepo.CreateRebalanceModel(newModel);
                }

                return(Ok());
                //rebRepo.CreateNewModel(model, User.Identity.GetUserId());
            }
            return(BadRequest());
        }
 public void CreateNewModel(RebalanceCreationModel model, string adviserUserId)
 {
     //add model and link it to the corresponding client group
     throw new NotImplementedException();
 }
        public IHttpActionResult CreateNewModel_Client(RebalanceCreationModel model) {
            Client client = edisRepo.GetClientSync(User.Identity.GetUserId(), DateTime.Now);
            ClientGroup clientGroup = edisRepo.GetClientGroupSync(client.ClientGroupId, DateTime.Now);

            if (model != null) {
                List<Domain.Portfolio.Rebalance.TemplateDetailsItemParameter> parameters = new List<Domain.Portfolio.Rebalance.TemplateDetailsItemParameter>();
                foreach (var parameter in model.parameters) {
                    parameters.Add(new Domain.Portfolio.Rebalance.TemplateDetailsItemParameter {
                        EquityId = parameter.parameterId,
                        ItemName = parameter.parameterName,
                        CurrentWeighting = (double)parameter.weighting,
                        ModelId = model.modelId,
                        identityMetaKey = parameter.identityMetaKey
                    });
                };

                Domain.Portfolio.Rebalance.RebalanceModel newModel = new Domain.Portfolio.Rebalance.RebalanceModel {
                    ModelId = model.modelId,
                    ClientId = User.Identity.GetUserId(),
                    ClientGroupId = clientGroup.Id,
                    ModelName = model.name,
                    ProfileId = (int)Enum.Parse(typeof(RebalanceModelProfile), model.profileId),
                    TemplateDetailsItemParameters = parameters
                };

                if (model.modelId != null) {
                    edisRepo.UpdateRebalanceModel(newModel);
                } else {
                    edisRepo.CreateRebalanceModel(newModel);
                }

                return Ok();
                //rebRepo.CreateNewModel(model, User.Identity.GetUserId());
            }
            return BadRequest();
        }