Example #1
0
        public bool AddStudent(StudentPostDto student)
        {
            Student std = new Student();

            std.Name            = student.Name;
            std.Email           = student.Email;
            std.Contact         = student.Contact;
            std.Password        = student.Password;
            std.ConfirmPassword = student.ConfirmPassword;
            using (var context = new SchoolContext())
            {
                context.Students.Add(std);
                List <StudentCourse> courselist = new List <StudentCourse>();
                foreach (var courseid in student.CoursesList)
                {
                    StudentCourse scourse = new StudentCourse();
                    scourse.StudentId = std.Id;
                    scourse.CourseId  = courseid;
                    courselist.Add(scourse);
                }
                context.StudentCourses.AddRange(courselist);
                context.SaveChanges();
                return(true);
            }
        }
        public static bool SendEvaluation(StudentPostDto studentDto, RegistrationDto registrationDto)
        {
            var proxy = new TestProxy
            {
                Credentials = new NetworkCredential(registrationDto.TeacherLogin, registrationDto.TeacherPassword),
                UseIntTag   = true
            };

            try
            {
                var result = proxy.GetStateName(registrationDto.CourseAbbrv, registrationDto.Year,
                                                registrationDto.Sem, registrationDto.WisVariantId, studentDto.login,
                                                25, "", registrationDto.TeacherLogin,
                                                DateTime.Today, 1);
                if (result != "OK Change" && result != "NO Change")
                {
                    return(false);
                }

                return(true);
            }
            catch (XmlRpcFaultException ex)
            {
                Debug.WriteLine(ex.Message);
            }
            return(false);
        }
 public IHttpActionResult PostStudent(StudentPostDto student)
 {
     if (student == null)
     {
         return(BadRequest());
     }
     service.AddStudent(student);
     return(Ok("Student has been Added"));
 }
Example #4
0
        public ActionResult AddStudent(StudentPostDto student)
        {
            var studentModel = new Student
            {
                Name            = student.Name,
                Email           = student.Email,
                Contact         = student.Contact,
                Password        = student.Password,
                ConfirmPassword = student.ConfirmPassword
            };
            var id        = studentrepo.AddStudentByStoredProcedure(studentModel);
            int studentId = Convert.ToInt32(id);

            studentrepo.AddStudentCoursesBySp(studentId, student.CoursesList);
            return(RedirectToAction("StudentList"));
        }
        public IHttpActionResult GetVoted(int studentId, int id)
        {
            StudentPost studentPost = db.StudentPosts.FirstOrDefault(p => p.StudentId == studentId && p.PostId == id);

            if (studentPost == null)
            {
                return(NotFound());
            }
            StudentPostDto dto = new StudentPostDto()
            {
                PostId    = studentPost.PostId,
                StudentId = studentPost.StudentId,
                Voted     = studentPost.Voted
            };

            return(Ok(dto));
        }
        public ActionResult <StudentGetDto> Post([FromBody] StudentPostDto studentDto)
        {
            var studentToCreate = new Student
            {
                FirstName = studentDto.FirstName,
                LastName  = studentDto.LastName
            };

            _context.Students.Add(studentToCreate);

            _context.SaveChanges();

            var studentToReturn = new StudentGetDto
            {
                Id        = studentToCreate.Id,
                FirstName = studentToCreate.FirstName,
                LastName  = studentToCreate.LastName,
            };

            return(Ok(studentToReturn));
        }
Example #7
0
 public bool UpdateStudent(StudentPostDto studentPost)
 {
     using (SchoolContext db = new SchoolContext())
     {
         Student std = new Student();
         std.Id              = studentPost.Id;
         std.Name            = studentPost.Name;
         std.Email           = studentPost.Email;
         std.Contact         = studentPost.Contact;
         std.Password        = studentPost.Password;
         std.ConfirmPassword = studentPost.ConfirmPassword;
         db.Entry(std).State = EntityState.Modified;
         var stdPreCourses = db.StudentCourses.Where(x => x.StudentId == studentPost.Id).ToList();
         if (stdPreCourses != null)
         {
             db.StudentCourses.RemoveRange(stdPreCourses);
             db.SaveChanges();
             List <StudentCourse> courseList = new List <StudentCourse>();
             if (studentPost.CoursesList != null)
             {
                 foreach (var Course in studentPost.CoursesList)
                 {
                     StudentCourse course_Obj = new StudentCourse();
                     course_Obj.StudentId = studentPost.Id;
                     course_Obj.CourseId  = Convert.ToInt32(Course);
                     courseList.Add(course_Obj);
                     course_Obj.CourseId = Convert.ToInt32(Course);
                     courseList.Add(course_Obj);
                 }
                 db.StudentCourses.AddRange(courseList);
                 db.SaveChanges();
             }
         }
     }
     return(true);
 }
Example #8
0
 public ActionResult UpdateStudentRecord(StudentPostDto studentPost)
 {
     studentrepo.UpdateStudent(studentPost);
     return(RedirectToAction("StudentList"));
 }