Exemplo n.º 1
0
        public async static Task <PostOrPutResultModel> GetPutEmpresaBindingModel(this IEntityService <Empresa> service, GetBindingModel model)
        {
            var result = await service.MongoService.GetMongoObject <EmpresaClienteMongoModel>(model.Id);

            if (result == null)
            {
                result = await service.MongoService.GetMongoObjectByParentId <EmpresaClienteMongoModel>(model.Id);

                if (result == null)
                {
                    return new PostOrPutResultModel {
                               IsValid = false, StatusCode = 404
                    }
                }
                ;
            }

            var binding = result.CreateInstanceOf <PutEmpresaBindingModel>();

            if (string.IsNullOrEmpty(binding.InscricaoEstadual))
            {
                binding.InscricaoEstadual = "ISENTO";
            }

            if (string.IsNullOrEmpty(binding.InscricaoMunicipal))
            {
                binding.InscricaoMunicipal = "ISENTO";
            }

            await service.MongoService.SetDropDownOptions <PutEmpresaBindingModel>(binding);

            return(new PostOrPutResultModel {
                IsValid = true, BindingModel = binding
            });
        }
Exemplo n.º 2
0
        public async static Task <BaseResultModel> GetEmpresaByParentIdAsync(this IEntityService <Empresa> service, GetBindingModel model)
        {
            var filtersEmpresa = new List <FilterDefinition <EmpresaClienteMongoModel> >();
            var builderEmpresa = Builders <EmpresaClienteMongoModel> .Filter;

            filtersEmpresa.Add(builderEmpresa.Eq(p => p.ParentId, model.Id));

            return(await service.GetEmpresasFromFilter(filtersEmpresa));
        }