public ActionResult <IEnumerable <IEmpresa> > Gets([FromBody] DataTablesResponseViewModel model) { string filtro = model.Search.Value; int ordernar = model.Order[0].Column; string ordernarDirecao = model.Order[0].Dir; int _draw = model.Draw; int startRec = model.Start; int pageSize = model.Length; IsolationLevel isolationLevel = IsolationLevel.ReadUncommitted; Services <IEmpresa> services = Services <IEmpresa> .Create(FactoryServices.Create(isolationLevel).getEmpresa()); IList <IEmpresa> empresas = services.Gets(startRec, filtro, pageSize); IList <EmpresaTableViewModel> tablesEempresa = converterEmpresaViewModelParaEmpresaTableViewModel(empresas); List <EmpresaTableViewModel> empresasOrdenadas = ordenacaoTableEmpresa(ordernar, ordernarDirecao, tablesEempresa); int totalRegistros = services.totalDeRegistros; var retorno = this.Json(new { draw = _draw, recordsTotal = totalRegistros, recordsFiltered = totalRegistros, data = empresasOrdenadas }); return(retorno); }
public void CreateHash() { IsolationLevel isolationLevel = IsolationLevel.ReadUncommitted; Services <IEmpresa> services = Services <IEmpresa> .Create(FactoryServices.Create(isolationLevel).getEmpresa()); string codigoHash = services.createHashCodigo("bhhhghghggh").Result; }
public async Task <ActionResult <string> > Post([FromBody] EmpresaViewModel empresa) { if (ModelState.IsValid) { IsolationLevel isolationLevel = IsolationLevel.ReadUncommitted; Services <IEmpresa> services = Services <IEmpresa> .Create(FactoryServices.Create(isolationLevel).getEmpresa()); empresa.Status = "AT"; IEmpresa _empresa = await services.IncluirAsync(empresa); return(Json(_empresa.Id.ToString())); } return(Json(empresa)); }
public void CreateTeste() { IsolationLevel isolationLevel = IsolationLevel.ReadUncommitted; Services <IEmpresa> services = Services <IEmpresa> .Create(FactoryServices.Create(isolationLevel).getEmpresa()); IEmpresa empresa = new EmpresaViewModel(); empresa.CnpjCpf = "5475778787"; empresa.Email = "*****@*****.**"; empresa.Nome = "Teste"; empresa.NomeFantasia = "Teste"; empresa.Status = "AT"; services.IncluirAsync(empresa); }
public void CreateTeste() { IsolationLevel isolationLevel = IsolationLevel.ReadUncommitted; Services <IdentityRole> services = Services <IdentityRole> .Create(FactoryServices.Create(isolationLevel).getFuncao()); IdentityRole funcao = new IdentityRole(); funcao.Id = Guid.NewGuid().ToString(); funcao.ConcurrencyStamp = DateTimeOffset.Now.TimeOfDay.ToString(); funcao.Name = "Operador do sistema"; funcao.NormalizedName = "OperadorSistema"; Task <IdentityRole> retorno = services.IncluirAsync(funcao); }
public async Task <IActionResult> Registrar([FromBody] Usuario model) { if (ModelState.IsValid) { IdentityUser identityUser = model.toIdentityUser(); var manager = _userManager.CreateAsync(identityUser, model.PasswordHash); var result = await manager; if (result.Succeeded) { IsolationLevel isolationLevel = IsolationLevel.ReadUncommitted; Services <IEmpresaUsuario> services = Services <IEmpresaUsuario> .Create(FactoryServices.Create(isolationLevel).getEmpresaUsuario()); IEmpresaUsuario empresaUsuario = new EmpresaUsuarioViewModel(); empresaUsuario.EmpresaId = Guid.Parse(model.EmpresaUsuario.EmpresaId); empresaUsuario.UsuarioId = identityUser.Id; empresaUsuario.Status = "AT"; string valorCriptografar = string.Concat("{0}:{1}", empresaUsuario.EmpresaId, identityUser.Email); empresaUsuario.Key = await services.createHashCodigo(valorCriptografar); await services.IncluirAsync(empresaUsuario); _logger.LogInformation("Usuário criado com nova senha"); var code = await _userManager.GenerateEmailConfirmationTokenAsync(identityUser); var callbackUrl = Url.EmailConfirmarLink(identityUser.Id, code, Request.Scheme); await _emailSender.SendEmailConfirmacaoAsync(identityUser.Email, callbackUrl); await _signInManager.SignInAsync(identityUser, isPersistent : false); _logger.LogInformation("Email de confirmação do usuário criado"); return(Json(identityUser)); } AddErrors(result); return(Json(result.Errors.FirstOrDefault().Description)); } return(Json(model)); }