//protected override object AddNewCore()
        //{
        //    var model = new PlanoComercial(
        //        Guid.NewGuid().ToString(),
        //        null,
        //        6000,
        //        20
        //    );

        //    var viewModel = PlanoComercialViewModel.From(model);

        //    OnAddNew(viewModel);

        //    return viewModel;
        //}

        protected override async void OnAddNew(PlanoComercialViewModel viewModel)
        {
            //item.BindingList = this;

            var model = new PlanoComercial(
                Guid.NewGuid().ToString(),
                null,
                6000
                );

            viewModel.model = model;

            await repositorioDePlanosComerciais.Add(model);

            //viewModel.Itens.planoComercial = viewModel;

            base.OnAddNew(viewModel);
        }
Example #2
0
        public async Task <IRespostaDeCriacaoDePlanoComercial> CriaPlanoComercial(ISolicitacaoDeCriacaoDePlanoComercial solicitacao)
        {
            await unitOfWork.BeginTransaction();

            try
            {
                //var fabricante = await repositorioDeModelos.ObtemFabricante(solicitacao.FabricanteId);

                var planoComercial = new PlanoComercial(
                    solicitacao.Id,
                    solicitacao.Nome
                    //solicitacao.Descricao,
                    //solicitacao.CustoPadrao,
                    //fabricante,
                    //componente
                    );

                //

                await repositorioDePlanosComerciais.Add(planoComercial);

                //

                await unitOfWork.Commit();

                //

                return(new RespostaDeCriacaoDePlanoComercial
                {
                    Id = solicitacao.Id,
                });
            }
            catch (Exception e)
            {
                await unitOfWork.Rollback();

                throw;
            }
        }