Ejemplo n.º 1
0
        public ActionResult ProjectDetails(EnrollmentRequests ers)
        {
            if (string.IsNullOrEmpty(ers.RequestMessage))
            {
                ModelState.AddModelError("RequestMessage", "Message should be set");
            }
            else if (ers.RequestMessage.Length < 10)
            {
                ModelState.AddModelError("RequestMessage", "Message should contain at least 10 characters");
            }
            if (ModelState.IsValid)
            {
                db.EnrollmentRequests.Add(ers);
                db.SaveChanges();
            }

            IEnumerable <Enrollments> enrollments = db.Enrollments.Where(c => c.ProjectId == ers.ProjectId).Include(p => p.User);

            ViewBag.Enrollments = enrollments;
            IEnumerable <EnrollmentRequests> er = db.EnrollmentRequests.ToList();

            ViewBag.EnrollmentRequests = er;
            ViewBag.EnrollmentRequest  = db.EnrollmentRequests.Where(c => c.ProjectId == ers.ProjectId).SingleOrDefault();
            ViewBag.Enr = ers;
            return(View(db.Projects.Where(c => c.Id == ers.ProjectId).
                        Include(p => p.Specification).Include(p => p.PostedBy).SingleOrDefault()));
        }
Ejemplo n.º 2
0
        public ActionResult RequestProcessing(string user_id, int project_id, string accept, string reject)
        {
            EnrollmentRequests er = db.EnrollmentRequests.Where(p => p.ProjectId == project_id && p.UserId == user_id).SingleOrDefault();

            if (er != null)
            {
                Enrollments enrollment = new Enrollments();
                enrollment.UserId    = user_id;
                enrollment.ProjectId = project_id;
                if (accept != null)
                {
                    db.Enrollments.Add(enrollment);
                    db.EnrollmentRequests.Remove(er);
                }
                if (reject != null)
                {
                    db.EnrollmentRequests.Remove(er);
                }
            }


            db.SaveChanges();

            return(RedirectToAction("Index"));
        }