Exemplo n.º 1
0
        //POST : /api/Internships/proposeInternship
        public async Task <ActionResult <Internships> > ProposeInternship(IntershipModel model)
        {
            string userId = User.Claims.First(c => c.Type == "UserID").Value;
            var    user   = await _userManager.FindByIdAsync(userId);

            var resp = await _context.CompaniesResp.FirstAsync(c => c.UserId == user.Id);

            Company comp = await _context.Company.FindAsync(resp.CompanyId);

            Internships newInternship = new Internships()
            {
                Description = model.Description,
                Role        = model.Role,
                Vagas       = model.Vagas,
                CompanyResp = resp,
                Company     = comp,
                Aceite      = false,
                Proposta    = true
            };

            await _context.TFCs.AddAsync(newInternship);

            await _context.SaveChangesAsync();

            return(Ok(newInternship));
        }
Exemplo n.º 2
0
        public async Task <ActionResult <Internships> > PostInternships(IntershipModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }


            Internships i = new Internships()
            {
                Vagas       = model.Vagas,
                Proposta    = true,
                Aceite      = false,
                Description = model.Description,
                Role        = model.Role,
                //CompanyId = c.Id
            };

            _context.TFCs.Add(i);
            await _context.SaveChangesAsync();

            return(Ok(i));
        }