Get a company record

Asked

Viewed 40 times

1

I am new in c#, I would like help to pick up and registered company by user X, what I need is the function Businessman

Functioncontroller

public async Task<IActionResult> Create()
    {
        _logger.LogInformation("Novo funcionario");
        var empresa = await _empresaRepositorio.PegarEmpresaLogado(usuarioID);
        var funcionario = new Funcionario {EmpresaId = empresa.EmpresaId };
        return View(funcionario);
    }

Models.Company

public class Empresa
{
    public int EmpresaId { get; set; }

    [Required(ErrorMessage = "Campo obrigatório")]
    public string CNPJ { get; set; }
    ............

    public string UsuarioId { get; set; }
    public Usuario Usuario { get; set; }

    public ICollection<Funcionario> Funcionarios { get; set; }
}

Models.Funcionario

public class Funcionario
{
    public int FuncId { get; set; }

    [Required(ErrorMessage = "Campo obrigatório")]
    [StringLength(100, ErrorMessage = "Use menos caracteres")]
    public string Nome { get; set; }
    ...........
    public string Demissao { get; set; }

    public int EmpresaId { get; set; }
    public Empresa Empresa { get; set; }

}
  • you need to get the logged-in user (who is registering)? or the company they are registering for? or the company that this user who is registering belongs to?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.