public Models.TbEmpregado ConvertReqparaTbEmpregado(Models.Request.RequestGerente.RequestGerente req, Models.TbLogin req2) { Models.TbEmpregado ctx = new Models.TbEmpregado(); ctx.NmEmpregado = req.nomefuncionario; ctx.DtNascimento = req.nascimentofuncionario; ctx.DsCpf = req.cpf; ctx.DsCep = req.cep; ctx.DsRg = req.rg; ctx.DsCarteiraTrabalho = req.carteiratrabalho; ctx.DsCargo = "funcionario"; ctx.DsCargaHorariaSemanal = req.cargahorariasemanal; ctx.VlSalario = req.salario; ctx.IdLogin = req2.IdLogin; return(ctx); }
public Models.TbLogin criaremailfunc(Models.Request.RequestGerente.RequestGerente req) { Models.TbLogin conta = new Models.TbLogin(); string primeironome = req.nomefuncionario.Substring(0, req.nomefuncionario.IndexOf(" ")); int qtd = req.nomefuncionario.IndexOf(" ") + 1; string segundonome = req.nomefuncionario.Substring(req.nomefuncionario.LastIndexOf(" ")); string email = primeironome + segundonome + "@gmail.com"; string espacos = email.Replace(" ", "_"); int requestdia = req.nascimentofuncionario.Day; string dia = ""; int requestmes = req.nascimentofuncionario.Month; string mes = ""; if (requestdia < 10) { dia = "0" + req.nascimentofuncionario.Day.ToString(); } else { dia = req.nascimentofuncionario.Day.ToString(); } if (requestmes < 10) { mes = "0" + req.nascimentofuncionario.Month.ToString(); } else { mes = req.nascimentofuncionario.Month.ToString(); } string senha = dia + mes + req.nascimentofuncionario.Year.ToString(); conta.DsEmail = espacos; conta.DsSenha = senha; conta.DsPerfil = "funcionario"; return(conta); }
public Models.Response.GerenteResponse.FuncionarioGerenteResponse cadastrarfunc(Models.Request.RequestGerente.RequestGerente req) { Models.TccContext db = new Models.TccContext(); Utils.ConversorGerenteUtils.ConversorGerenteUtils modelotb = new Utils.ConversorGerenteUtils.ConversorGerenteUtils(); Utils.ConversorGerenteUtils.GerarEmailFuncionario gerarnovoemailfunc = new Utils.ConversorGerenteUtils.GerarEmailFuncionario(); Models.TbLogin novoemail = gerarnovoemailfunc.criaremailfunc(req); db.TbLogin.Add(novoemail); db.SaveChanges(); Models.TbEmpregado novofunc = modelotb.ConvertReqparaTbEmpregado(req, novoemail); db.TbEmpregado.Add(novofunc); db.SaveChanges(); Models.Response.GerenteResponse.FuncionarioGerenteResponse result = modelotb.ConverttbparaResponse(novofunc); return(result); }