public async Task <IActionResult> OnPostSaveAsync() { if (Input.Pessoa == null) { return(Page()); } //var user = await _userManager.GetUserAsync(User); Input.Protocolo = await GetProtoloco(); Input.Data = DateTime.Now; Input.Status = "Ativo"; Input.Ativo = true; Input.Owner_AppUser_Id = User.Identity.Name; var atendimento = new Atendimento() { Protocolo = Input.Protocolo, Data = Input.Data, Status = Input.Status, Ativo = Input.Ativo, Owner_AppUser_Id = Input.Owner_AppUser_Id }; var pessoa = _appServicePessoa.GetById(Input.Pessoa.Id); if (pessoa != null) { atendimento.Pessoa = pessoa; } if (Input.Empresa != null) { var empresa = _appServiceEmpresa.GetById(Input.Empresa.Id); if (empresa != null) { atendimento.Empresa = empresa; } } _appServiceAtendimento.Add(atendimento); return(RedirectToPage("./Novo")); }