public IEnumerable <TeacherViewModel> Get()
        {
            int userId = Convert.ToInt32(this.User.FindFirstValue(ClaimTypes.Name));
            int coorid = _coordinator.GetCoordinatorId(userId);

            return(_teacher.GetAllTeachersOfCoordinator(coorid));
        }
Esempio n. 2
0
        public HttpResponseMessage Post([FromBody] EnrolViewModel enrol)
        {
            if (ModelState.IsValid)
            {
                int userId    = Convert.ToInt32(this.User.FindFirstValue(ClaimTypes.Name));
                int coorid    = _coordinator.GetCoordinatorId(userId);
                var tempEnrol = AutoMapper.Mapper.Map <Enrolment>(enrol);
                tempEnrol.CreatedBy = coorid;
                _enrolment.InsertEnrolment(tempEnrol);


                var response = new HttpResponseMessage()
                {
                    StatusCode = HttpStatusCode.OK
                };

                return(response);
            }
            else
            {
                var response = new HttpResponseMessage()
                {
                    StatusCode = HttpStatusCode.BadRequest
                };

                return(response);
            }
        }
        public HttpResponseMessage Post([FromBody] CourseViewModel course)
        {
            if (ModelState.IsValid)
            {
                int userId     = Convert.ToInt32(this.User.FindFirstValue(ClaimTypes.Name));
                int coorid     = _coordinator.GetCoordinatorId(userId);
                var tempCourse = AutoMapper.Mapper.Map <Course>(course);
                tempCourse.CreatedBy = coorid;
                _courses.InsertCourse(tempCourse);


                var response = new HttpResponseMessage()
                {
                    StatusCode = HttpStatusCode.OK
                };

                return(response);
            }
            else
            {
                var response = new HttpResponseMessage()
                {
                    StatusCode = HttpStatusCode.BadRequest
                };

                return(response);
            }
        }
Esempio n. 4
0
        public HttpResponseMessage Post([FromBody] StudentViewModel student)
        {
            if (ModelState.IsValid)
            {
                int userId    = Convert.ToInt32(this.User.FindFirstValue(ClaimTypes.Name));
                int coorid    = _coordinator.GetCoordinatorId(userId);
                var tempUsers = AutoMapper.Mapper.Map <Users>(student);
                tempUsers.CreatedDate = DateTime.Now;
                tempUsers.Createdby   = userId;
                tempUsers.Password    = EncryptLib.EncryptText(student.Password);
                _users.InsertUsers(tempUsers);
                var tempStudent = AutoMapper.Mapper.Map <Student>(student);
                tempStudent.UserID       = tempUsers.UserId;
                tempStudent.DepartmentID = _coordinator.GetCoordinatorDepartmentId(coorid);
                _student.InsertStudent(tempStudent);
                UsersInRoles usersInRoles = new UsersInRoles();
                usersInRoles.RoleId = 2;
                usersInRoles.UserId = tempStudent.UserID;
                _usersInRoles.AssignRole(usersInRoles);

                var response = new HttpResponseMessage()
                {
                    StatusCode = HttpStatusCode.OK
                };

                return(response);
            }
            else
            {
                var response = new HttpResponseMessage()
                {
                    StatusCode = HttpStatusCode.BadRequest
                };

                return(response);
            }
        }
        public HttpResponseMessage Post([FromBody] SectionViewModel section)
        {
            if (ModelState.IsValid)
            {
                if (_section.CheckSectionExits(section.SectionNo, section.CourseID))
                {
                    var responseCheck = new HttpResponseMessage()
                    {
                        StatusCode = HttpStatusCode.Conflict
                    };

                    return(responseCheck);
                }

                int userId      = Convert.ToInt32(this.User.FindFirstValue(ClaimTypes.Name));
                int coorid      = _coordinator.GetCoordinatorId(userId);
                var tempSection = AutoMapper.Mapper.Map <Section>(section);
                tempSection.CreatedBy = coorid;
                _section.InsertSection(tempSection);


                var response = new HttpResponseMessage()
                {
                    StatusCode = HttpStatusCode.OK
                };

                return(response);
            }
            else
            {
                var response = new HttpResponseMessage()
                {
                    StatusCode = HttpStatusCode.BadRequest
                };

                return(response);
            }
        }