示例#1
0
        public ActionResult DeleteConfirmed(string id)
        {
            StudentInternship studentInternship = db.StudentInternships.Find(id);

            db.StudentInternships.Remove(studentInternship);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#2
0
        public ActionResult Create([Bind(Include = "SubmitedResume,Updates")] StudentInternship studentInternship, HttpPostedFileBase SubmitedResume, string internshipId = null)
        {
            if (ModelState.IsValid)
            {
                var userId = Session["UserId"].ToString();
                // ViewBag.InternshipId = id;
                //ViewBag.SubmitedResume = new SelectList(db.Resumes, "Id", "Name");
                //ViewBag.StudentId = new SelectList(db.Students, "StudentId", "Name");
                studentInternship.StudentId    = Session["UserId"].ToString();
                studentInternship.Stage        = "0";
                studentInternship.DateCreated  = DateTime.Today;
                studentInternship.InternshipId = Session["InternshipId"].ToString();
                var studId = db.Students.Where(st => st.UserId == userId).FirstOrDefault().StudentId;
                studentInternship.StudentId               = studId;
                studentInternship.StatusOfApplication     = false;
                studentInternship.Completed               = false;
                studentInternship.StarredForFurtherReview = false;
                studentInternship.StudentUserId           = userId;
                studentInternship.Completed               = false;
                studentInternship.StarredForFurtherReview = false;
                studentInternship.Hidden = false;


                Data.Resume fileToSave = new Data.Resume();

                if (SubmitedResume != null)
                {
                    var    fileName        = Path.GetFileName(SubmitedResume.FileName);
                    var    directoryToSave = Server.MapPath(Url.Content(ContentPath));
                    string GuidFileName    = Guid.NewGuid().ToString() + ".pdf";
                    var    pathToSave      = Path.Combine(directoryToSave, GuidFileName);
                    SubmitedResume.SaveAs(pathToSave);
                    fileToSave.Name = GuidFileName;
                    fileToSave.Path = pathToSave;
                    fileToSave.Id   = Guid.NewGuid().ToString();
                    db.Resumes.Add(fileToSave);

                    studentInternship.Resume = fileToSave;
                }


                db.StudentInternships.Add(studentInternship);
                db.SaveChanges();


                return(RedirectToAction("StudentProfile", "Student"));
            }

            ViewBag.InternshipId   = new SelectList(db.Internships, "InternshipId", "FirmOrganizerId", studentInternship.InternshipId);
            ViewBag.SubmitedResume = new SelectList(db.Resumes, "Id", "Name", studentInternship.SubmitedResume);
            ViewBag.StudentId      = new SelectList(db.Students, "StudentId", "Name", studentInternship.StudentId);
            return(View(studentInternship));
        }
示例#3
0
 public ActionResult Edit([Bind(Include = "StudentId,InternshipId,StudentUserId,DateCreated,Completed,Updates,SubmitedResume,StatusOfApplication,StudentResumeId,StarredForFurtherReview")] StudentInternship studentInternship)
 {
     if (ModelState.IsValid)
     {
         db.Entry(studentInternship).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.InternshipId   = new SelectList(db.Internships, "InternshipId", "FirmOrganizerId", studentInternship.InternshipId);
     ViewBag.SubmitedResume = new SelectList(db.Resumes, "Id", "Name", studentInternship.SubmitedResume);
     ViewBag.StudentId      = new SelectList(db.Students, "StudentId", "Name", studentInternship.StudentId);
     return(View(studentInternship));
 }
示例#4
0
        // GET: StudentInternships/Details/5
        public ActionResult Details(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            StudentInternship studentInternship = db.StudentInternships.Find(id);

            if (studentInternship == null)
            {
                return(HttpNotFound());
            }
            return(View(studentInternship));
        }
        public ActionResult StudentStuff(string id, string id2, string newStage, string rate = null)
        {
            StudentInternship studentInternship = entities.StudentInternships.Where(st => st.StudentId == id && st.InternshipId == id2).ToList().FirstOrDefault();

            if (studentInternship == null)
            {
                return(HttpNotFound());
            }
            if (newStage != null)
            {
                studentInternship.Stage = newStage;
                if (rate != null)
                {
                    studentInternship.Internship.Description += rate;
                }
                entities.SaveChanges();
            }
            return(RedirectToAction("StudentProfile", "Student"));
        }
        public async Task <ActionResult <StudentInternship> > GetStudentInternship(int studentId, int InternshipId)
        {
            List <StudentInternship> studentInternships = await _context.StudentInternships.ToListAsync();

            StudentInternship result = null;

            foreach (StudentInternship studentInternship in studentInternships)
            {
                if (studentInternship.InternshipId == InternshipId && studentInternship.StudentId == studentId)
                {
                    result = studentInternship;
                }
            }

            if (result == null)
            {
                return(NotFound());
            }

            return(result);
        }
        public async Task <ActionResult <StudentInternship> > PostStudentInternship(StudentInternship studentInternship)
        {
            _context.StudentInternships.Add(studentInternship);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (StudentInternshipExists(studentInternship.StudentId, studentInternship.InternshipId))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetStudentInternship", new { id = studentInternship.StudentId }, studentInternship));
        }
示例#8
0
        // GET: StudentInternships/Edit/5
        public ActionResult Edit(string id, string id2, string newStage = null)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            StudentInternship studentInternship = db.StudentInternships.Where(st => st.StudentId == id && st.InternshipId == id2).ToList().FirstOrDefault();

            if (studentInternship == null)
            {
                return(HttpNotFound());
            }
            if (newStage != null)
            {
                studentInternship.Stage = newStage;
                db.SaveChanges();
            }
            //ViewBag.InternshipId = new SelectList(db.Internships, "InternshipId", "FirmOrganizerId", studentInternship.InternshipId);
            //ViewBag.SubmitedResume = new SelectList(db.Resumes, "Id", "Name", studentInternship.SubmitedResume);
            //ViewBag.StudentId = new SelectList(db.Students, "StudentId", "Name", studentInternship.StudentId);
            return(View(studentInternship));
        }
        public async Task <IActionResult> PutStudentInternship(int studentId, int InternshipId, StudentInternship studentInternship)
        {
            if (studentId != studentInternship.StudentId && InternshipId != studentInternship.InternshipId)
            {
                return(BadRequest());
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!StudentInternshipExists(studentId, InternshipId))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }