Beispiel #1
0
        public async Task <IActionResult> PutInternships(int id, Internships internships)
        {
            if (id != internships.ID)
            {
                return(BadRequest());
            }

            _context.Entry(internships).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!InternshipsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #2
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));
        }
Beispiel #3
0
        // PUT: api/Internships/rejectPropose/1
        public async Task <IActionResult> PutRejectPropose(int id)
        {
            Internships i = await _context.TFCs.OfType <Internships>().FirstOrDefaultAsync(i => i.ID == id);

            if (i.Proposta == false)
            {
                return(BadRequest("This internship is not a proposed internship so u cant accept it"));
            }
            i.Aceite   = false;
            i.Proposta = false;

            _context.Update(i);
            await _context.SaveChangesAsync();

            return(Ok(i));
        }
Beispiel #4
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));
        }
        protected override async void OnViewLoaded(object view)
        {
            var internships = await DataAccess.GetThisYearsInternships();

            Internships.AddRange(internships);
        }