Ejemplo n.º 1
0
        public IActionResult Update(int id, [FromBody] Enrollments enrollment)
        {
            if (enrollment == null || enrollment.Id != id)
            {
                return(BadRequest());
            }

            var enr = _context.Enrollments.SingleOrDefault(x => x.Id == id);

            if (enr == default(Enrollments))
            {
                return(NotFound());
            }

            enr.StudentId      = enrollment.StudentId;
            enr.CourseId       = enrollment.CourseId;
            enr.AcademicTermId = enrollment.AcademicTermId;
            enr.StartDate      = enrollment.StartDate;
            enr.EndDate        = enrollment.EndDate;
            enr.Notes          = enrollment.Notes;

            _context.Enrollments.Update(enr);
            _context.SaveChanges();
            return(new NoContentResult());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, Enrollments enrollments)
        {
            if (id != enrollments.IdEnrollment)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(enrollments);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EnrollmentsExists(enrollments.IdEnrollment))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(enrollments));
        }
Ejemplo n.º 3
0
        public int EnrollStudentInCourse(int StudentId, int CourseId, Enrollments enrolment)
        {
            try
            {
                if (_ctx.Enrollments.Any(e => e.Course.Id == CourseId && e.Student.Id == StudentId))
                {
                    return(2);
                }

                _ctx.Database.ExecuteSqlCommand("INSERT INTO Enrollments VALUES (@p0, @p1, @p2)",
                                                enrolment.EnrollmentDate, CourseId.ToString(), StudentId.ToString());

                return(1);
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException dbex)
            {
                foreach (var eve in dbex.EntityValidationErrors)
                {
                    string line = string.Format("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                                eve.Entry.Entity.GetType().Name, eve.Entry.State);

                    foreach (var ve in eve.ValidationErrors)
                    {
                        line = string.Format("- Property: \"{0}\", Error: \"{1}\"",
                                             ve.PropertyName, ve.ErrorMessage);
                    }
                }
                return(0);
            }
            catch (Exception ex)
            {
                return(0);
            }
        }
        public HttpResponseMessage Post(int courseId, [FromUri] string userName, [FromBody] Enrollments enrollment)
        {
            try
            {
                if (!TheRepository.CourseExists(courseId))
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Could not find Course"));
                }

                var student = TheRepository.GetStudents(userName);
                if (student == null)
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Could not find Student"));
                }

                var result = TheRepository.EnrollStudentInCourse(student.Id, courseId, enrollment);

                if (result == 1)
                {
                    return(Request.CreateResponse(HttpStatusCode.Created));
                }
                else if (result == 2)
                {
                    return(Request.CreateResponse(HttpStatusCode.NotModified, "Student already enrolled in this course"));
                }

                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, ex));
            }
        }
 public void deleteEnrollments(Section deleteSection)
 {
     foreach (var enrollment in Enrollments.Where(c => c.Section_Id == deleteSection.Id))
     {
         Enrollments.Remove(enrollment);
     }
 }
Ejemplo n.º 6
0
        public async Task <IActionResult> Edit(int id, [Bind("EnrollmentId,CustomerId,SeminarId,KitSelection,EnrollmentDate,Notes")] Enrollments enrollments)
        {
            if (id != enrollments.EnrollmentId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(enrollments);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EnrollmentsExists(enrollments.EnrollmentId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CustomerId"]   = new SelectList(_context.Customers, "CustomerId", "CustomerId", enrollments.CustomerId);
            ViewData["KitSelection"] = new SelectList(_context.Enrollments, "KitSelection", "KitSelection", enrollments.KitSelection);
            ViewData["SeminarId"]    = new SelectList(_context.Seminars, "SeminarId", "SeminarId", enrollments.SeminarId);
            return(View(enrollments));
        }
Ejemplo n.º 7
0
        public static void EnrollStudent()
        {
            Console.WriteLine("Enter au-id of student to be enrolled");
            int auidInput = int.Parse(Console.ReadLine());

            Console.WriteLine("Enter id of course for student to be enrolled in");
            int courseIdInput = int.Parse(Console.ReadLine());

            using (var db = new AppDbContext())
            {
                var enrollment = new Enrollments()
                {
                    Status   = false,
                    CourseId = courseIdInput,
                    AUId     = auidInput
                };

                db.Enrollments.Add(enrollment);

                var student = db.Students.Single(s => s.AUId.Equals(auidInput));
                var course  = db.Courses.Single(c => c.CoursesId.Equals(courseIdInput));

                student.Enrollments.Add(enrollment);
                course.Enrollments.Add(enrollment);

                db.SaveChanges();

                Console.WriteLine($"Student {student.Name} has been enrolled to course {course.Name}");
            }
        }
        /// <summary>
        /// Return a list of enrollments from the files
        /// </summary>
        /// <returns>Enrollments</returns>
        public List <Enrollment> Extract_Enrollments()
        {
            this.Enrollments = new List <Enrollment>();
            foreach (var file in Files)
            {
                string filename = file.Substring(file.LastIndexOf(@"\")).Replace(@"\", "");
                filename = filename.Replace("user_", "");
                filename = filename.Replace(".xml", "");
                int             enrollNo = Convert.ToInt32(filename);
                XmlDataDocument xmldoc   = new XmlDataDocument();
                XmlNodeList     xmlnode;
                int             i   = 0;
                string          str = null;
                FileStream      fs  = new FileStream(file, FileMode.Open, FileAccess.Read);
                xmldoc.Load(fs);
                xmlnode = xmldoc.GetElementsByTagName("name");
                string name = "";
                for (i = 0; i <= xmlnode.Count - 1; i++)
                {
                    try
                    {
                        name = xmlnode[i].ChildNodes.Item(0).InnerText.Trim();
                    }
                    catch (Exception exc)
                    {
                    }
                }

                Enrollments.Add(new Enrollment {
                    Enrollment_No = enrollNo, Name = name, XML_File = file
                });
            }
            return(Enrollments);
        }
Ejemplo n.º 9
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"));
        }
Ejemplo n.º 10
0
        public async Task <IActionResult> Edit(int id, [Bind("CourseID,StudentID")] Enrollments enrollments)
        {
            if (id != enrollments.CourseID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(enrollments);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EnrollmentsExists(enrollments.CourseID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CourseID"]  = new SelectList(_context.Courses, "ID", "ID", enrollments.CourseID);
            ViewData["StudentID"] = new SelectList(_context.Students, "ID", "ID", enrollments.StudentID);
            return(View(enrollments));
        }
Ejemplo n.º 11
0
        public async Task <IActionResult> Save(EnrollmentsViewModel model)
        {
            if (!ModelState.IsValid)
            {
                PopulateSelectLists(model);
                return(View("Edit", model));
            }

            if (model.EnrollmentId == default(int))
            {
                var enrollment = new Enrollments();
                model.ApplyTo(enrollment);
                _db.Enrollments.Add(enrollment);
            }
            else
            {
                var enrollment = await _db.Enrollments.FindAsync(model.EnrollmentId);

                model.ApplyTo(enrollment);
            }

            await _db.SaveChangesAsync();

            return(RedirectToAction("List"));
        }
    private void BindGridView()
    {
        Enrollments       msts     = new Enrollments();
        List <Enrollment> Teachers = msts.FullDetails();

        grdTeacherInfo.DataSource = Teachers;
        grdTeacherInfo.DataBind();
    }
        public ActionResult DeleteConfirmed(int id)
        {
            Enrollments enrollments = db.Enrollments.Find(id);

            db.Enrollments.Remove(enrollments);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 14
0
 public EnrollmentModel Create(Enrollments enrollment)
 {
     return(new EnrollmentModel()
     {
         EnrollmentDate = enrollment.EnrollmentDate,
         Course = Create(enrollment.Course)
     });
 }
Ejemplo n.º 15
0
 public void Create(Enrollments enrollment)
 {
     using (var db = new ContosoDataDbContext())
     {
         db.Enrollment.Add(enrollment);
         db.SaveChanges();
     }
 }
Ejemplo n.º 16
0
        public virtual void RemoveEnrollment(Enrollment enrollment, string comment)
        {
            Enrollments.Remove(enrollment);

            var disenrollment = new Disenrollment(enrollment.Student, enrollment.Course, comment);

            Disenrollments.Add(disenrollment);
        }
Ejemplo n.º 17
0
        public List <Enrollments> List(bool HistoryFlag)
        {
            List <Enrollments> List = new List <Enrollments>();

            try
            {
                SqlCon.Open();
                var SqlCmd = new SqlCommand("[config].[uspReadEnrollments]", SqlCon)
                {
                    CommandType = CommandType.StoredProcedure
                };

                if (HistoryFlag == true)
                {
                    SqlParameter pHistoryFlag = new SqlParameter
                    {
                        ParameterName = "@HistoryFlag",
                        SqlDbType     = SqlDbType.Bit,
                        Value         = HistoryFlag
                    };
                    SqlCmd.Parameters.Add(pHistoryFlag);
                }

                using (var dr = SqlCmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        var detail = new Enrollments
                        {
                            EnrollmentID  = Convert.ToInt32(dr["EnrollmentID"]),
                            GroupID       = Convert.ToInt32(dr["GroupID"]),
                            GroupName     = dr["GroupName"].ToString(),
                            OpenRegister  = Convert.ToDateTime(dr["OpenRegister"]),
                            CloseRegister = Convert.ToDateTime(dr["CloseRegister"]),
                            ApprovalFlag  = Convert.ToBoolean(dr["ApprovalFlag"])
                        };
                        List.Add(detail);
                    }
                }
                if (SqlCon.State == ConnectionState.Open)
                {
                    SqlCon.Close();
                }
                foreach (var item in List)
                {
                    item.UserList = UserList(item.EnrollmentID);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            if (SqlCon.State == ConnectionState.Open)
            {
                SqlCon.Close();
            }
            return(List);
        }
        public ActionResult CboStudentPartial([ModelBinder(typeof(DevExpressEditorsBinder))] string studentId)
        {
            var model = new Enrollments()
            {
                StudentId = studentId
            };

            return(PartialView(model));
        }
Ejemplo n.º 19
0
        public async Task UnEnrollInCourse(int studentID, int courseId)
        {
            Enrollments enrollments = new Enrollments();

            enrollments.StudentId = studentID;
            enrollments.CourseId  = courseId;
            _context.Enrollments.Remove(enrollments);
            await _context.SaveChangesAsync();
        }
Ejemplo n.º 20
0
 public Student()
 {
     RegisterEventAppliers()
     .For <IStudentRegisteredEvent>(Apply)
     .For <IAddressChangedEvent>(Apply)
     .For <IStudentEnrolledEvent>(e => Enrollments.Add(new Enrollment(this, e.EnrollmentId)))
     .For <IEnrollmentEvent>(
         e => Enrollments.Single(enrollment => enrollment.Id == e.EnrollmentId).ApplyEvent(e));
 }
Ejemplo n.º 21
0
        private void ExecuteDelete(object obj)
        {
            object[] parameterArray = (object[])obj;
            Course   id             = parameterArray[0] as Course;

            Enrollments.Remove(id);
            objschool.Courses.Remove(id);
            (parameterArray[1] as DataGrid).Items.Refresh();
        }
        public IHttpActionResult Post([FromBody] EnrollmentsBindingModels enrollmentsBindingModel)
        {
            Enrollments enrollments   = new Enrollments();
            var         newEnrollment = Mapper.Map(enrollmentsBindingModel, enrollments);

            _service.CreateEnrollment(newEnrollment);
            _service.SaveChanges();
            return(Ok());
        }
    protected void makelink_delete(object sender, EventArgs e)
    {
        string strparm = (sender as ImageButton).CommandArgument;

        Enrollments msts   = new Enrollments();
        String      strerr = msts.DeleteEnroll(Convert.ToInt32(strparm));

        BindGridView();
    }
Ejemplo n.º 24
0
    private void BindControl()
    {
        Enrollments msts   = new Enrollments();
        Enrollment  enroll = msts.Details(Convert.ToInt32(Request.QueryString["EID"].ToString()));

        txtsalary.Text = enroll.Salary.ToString();
        ddldepartment.SelectedValue = enroll.Dept_ID.ToString();
        ddlTeacher.SelectedValue    = enroll.TEACHERID.ToString();
        ddlstate.SelectedValue      = enroll.StateID.ToString();
    }
Ejemplo n.º 25
0
        public async Task <IActionResult> Create(Enrollments enrollments)
        {
            if (ModelState.IsValid)
            {
                _context.Add(enrollments);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(enrollments));
        }
Ejemplo n.º 26
0
        private void ExecuteDigit(object obj)
        {
            Course objCourse = new Course()
            {
                ClassSize = 5, CourseId = 8, EndDate = DateTime.Now, InstructorId = 8, Name = "john", StartDate = DateTime.Now, Title = "JObjhj"
            };

            Enrollments.Add(objCourse);
            objschool.Courses.Add(objCourse);
            (obj as DataGrid).Items.Refresh();
        }
Ejemplo n.º 27
0
        public ActionResult LabDetailsStudent(int primKeyID)
        {
            if (primKeyID == 0)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Enrollments enrollment = db.Enrollments.Find(primKeyID); //βρίσκουμε τη συγκεκριμένη εγγραφή και εμφανίζουμε στον χρήστη τις πληροφορίες του εργαστηρίου του

            return(View(enrollment));
        }
Ejemplo n.º 28
0
 // Método para encontrar un enrollment a un Course mediante
 // el id del usuario
 public Enrollment findEnrollment(string UserId)
 {
     for (int i = 0; i < Enrollments.Count(); i++)
     {
         if (Enrollments.ElementAt(i).User.Id == UserId)
         {
             return(Enrollments.ElementAt(i));
         }
     }
     return(null);
 }
Ejemplo n.º 29
0
 public IActionResult Create([FromBody] Enrollments enrollment)
 {
     if (enrollment == null)
     {
         return(BadRequest());
     }
     enrollment.Id = AdoHelper.GetNextId("Enrollments", _connString);
     _context.Enrollments.Add(enrollment);
     _context.SaveChanges();
     return(CreatedAtRoute("GetEnrollment", new { id = enrollment.Id }, enrollment));
 }
Ejemplo n.º 30
0
        public virtual void Enroll(Course course, Grade grade)
        {
            if (Enrollments.Count >= 2)
            {
                throw new Exception("Cannot have more than 2 enrollments");
            }

            var enrollment = new Enrollment(this, course, grade);

            Enrollments.Add(enrollment);
        }
Ejemplo n.º 31
0
        public ViewResult DisplayByLastName(string id)
        {
            Enrollments test = new Enrollments { enrollments = new List<Enrollment> { new Enrollment { FirstName = "Umais", LastName = "Siddiqui" }, new Enrollment { FirstName = "Naveed", LastName = "Aziz" }, new Enrollment { FirstName = "Farah", LastName = "Aziz" }, new Enrollment { FirstName = "Tayyib", LastName = "Siddiqui" }, new Enrollment { FirstName = "Amir", LastName = "saleem" } } };
            IEnumerable<Enrollment> a=test.getEnrollmentmembersByLastName(id);
            string result = "";
            foreach (Enrollment b in a)
            {
                result += "  " + "FirstName:" + b.FirstName + " LastName:" + b.LastName;
            }

            return View("TestExtension", (object) String.Format("Here is the List:{0}",result));
        }